summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Karlitschek2012-08-15 02:11:46 (EDT)
committerPeter Karlitschek2012-08-15 02:11:46 (EDT)
commita4f5eddfa228fad9a4dd3418678e3ac9a0df064b (patch)
tree72c1fa5cd80a5ac23d683f01cc351b2800b2188c
parenta9c2535fa41c97a9a03cffe8ce9b53683c7bbfb4 (diff)
downloadorg.eclipse.etrice-a4f5eddfa228fad9a4dd3418678e3ac9a0df064b.zip
org.eclipse.etrice-a4f5eddfa228fad9a4dd3418678e3ac9a0df064b.tar.gz
org.eclipse.etrice-a4f5eddfa228fad9a4dd3418678e3ac9a0df064b.tar.bz2
Cpp generator - protocol class initialrefs/changes/23/8123/1
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/Main.classbin4923 -> 0 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppExtensions.classbin6214 -> 0 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend116
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppLanguageGenerator.classbin1809 -> 0 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppTranslationProvider.classbin3232 -> 0 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$1.classbin1639 -> 0 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$2.classbin1548 -> 0 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$3.classbin1639 -> 0 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$4.classbin1548 -> 0 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen.classbin21890 -> 0 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend254
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/MainGen.classbin2473 -> 0 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend52
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen$1.classbin1726 -> 0 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen$2.classbin1726 -> 0 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.classbin53380 -> 0 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend618
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/setup/GeneratorModule.classbin1484 -> 0 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java170
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java750
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java46
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java2207
22 files changed, 0 insertions, 4213 deletions
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/Main.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/Main.class
deleted file mode 100644
index 380777c..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/Main.class
+++ /dev/null
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppExtensions.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppExtensions.class
deleted file mode 100644
index 03021eb..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppExtensions.class
+++ /dev/null
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
deleted file mode 100644
index 361deea..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
- *
- *******************************************************************************/
-
-/*
- collection of convenience functions for code generation
-*/
-
-
-package org.eclipse.etrice.generator.cpp.gen
-
-import com.google.inject.Inject
-import com.google.inject.Singleton
-import org.eclipse.etrice.core.room.RoomClass
-import org.eclipse.etrice.core.room.Message
-import org.eclipse.etrice.generator.generic.ILanguageExtension
-import org.eclipse.etrice.generator.generic.AbstractTransitionChainGenerator
-import java.util.List
-import org.eclipse.xtext.util.Pair
-
-
-@Singleton
-class CppExtensions implements ILanguageExtension {
-
- @Inject AbstractTransitionChainGenerator chainGenerator
-
-
- override String getTypedDataDefinition(Message m) {
- return chainGenerator.generateTypedData(m)
- }
-
-
- def String getCppHeaderFileName(RoomClass rc) {rc.name+".h"}
- def String getCppSourceFileName(RoomClass rc) {rc.name+".cpp"}
-
- override String accessLevelPrivate() {""}
- override String accessLevelProtected() {""}
- override String accessLevelPublic() {""}
-
- override String memberAccess() {"this->"}
- override String selfPointer(String classname, boolean hasArgs) {""}
- override String selfPointer(boolean hasArgs) { "" }
-
- override String operationScope(String classname, boolean isDeclaration) {""}
-
-
- override String memberInDeclaration(String namespace, String member) {
- return member
- }
-
- override String memberInUse(String namespace, String member) {
- return namespace+"."+member
- }
-
- override boolean usesInheritance() {
- return true
- }
-
- override String genEnumeration(String name, List<Pair<String, String>> entries) {
- '''
- «FOR entry: entries»
- static const int «entry.first» = «entry.second»;
- «ENDFOR»
- '''.toString
- }
-
- override String booleanConstant(boolean b) {
- b.toString
- }
-
- override String pointerLiteral() { "" }
- override String nullPointer() { "null" }
- override String voidPointer() { "Object" }
-
- override String arrayDeclaration(String type, int size, String name, boolean isRef) {
- type+" "+name+"[]";
- }
-
- override String constructorName(String cls) {
- cls
- }
- override String destructorName(String cls) {
- cls+"_dtor"
- }
- override String constructorReturnType() {
- ""
- }
- override String destructorReturnType() {
- "void"
- }
-
- def getIncludeGuardString(String filename){
- '''_«filename.replaceAll("\\/.", "_").toUpperCase»_H_'''
- }
-
- def generateIncludeGuardBegin(String filename){'''
- #ifndef «filename.getIncludeGuardString»
- #define «filename.getIncludeGuardString»
- '''
- }
-
- def generateIncludeGuardEnd(String filename){'''
- #endif /* «filename.getIncludeGuardString» */
- '''
- }
-
-
-}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppLanguageGenerator.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppLanguageGenerator.class
deleted file mode 100644
index 2d41b79..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppLanguageGenerator.class
+++ /dev/null
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppTranslationProvider.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppTranslationProvider.class
deleted file mode 100644
index 0bed8d5..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppTranslationProvider.class
+++ /dev/null
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$1.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$1.class
deleted file mode 100644
index 94ff085..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$1.class
+++ /dev/null
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$2.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$2.class
deleted file mode 100644
index c94b321..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$2.class
+++ /dev/null
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$3.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$3.class
deleted file mode 100644
index ba3280a..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$3.class
+++ /dev/null
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$4.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$4.class
deleted file mode 100644
index 99adc7a..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$4.class
+++ /dev/null
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen.class
deleted file mode 100644
index 9179633..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen.class
+++ /dev/null
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
deleted file mode 100644
index 9fafaeb..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
+++ /dev/null
@@ -1,254 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Henrik Rentz-Reichert (initial contribution)
- *
- *******************************************************************************/
-
-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.Attribute
-import org.eclipse.etrice.core.room.ComplexType
-import org.eclipse.etrice.core.room.DataClass
-import org.eclipse.etrice.generator.generic.ProcedureHelpers
-import org.eclipse.etrice.generator.generic.RoomExtensions
-import org.eclipse.etrice.generator.generic.TypeHelpers
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess
-
-import org.eclipse.etrice.core.genmodel.base.ILogger
-import org.eclipse.etrice.core.genmodel.etricegen.Root
-
-import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
-
-
-@Singleton
-class DataClassGen {
-
- @Inject extension JavaIoFileSystemAccess fileAccess
- @Inject extension CppExtensions stdExt
- @Inject extension RoomExtensions roomExt
- @Inject extension ProcedureHelpers helpers
- @Inject extension TypeHelpers typeHelpers
- @Inject ILogger logger
-
- def doGenerate(Root root) {
- logger.logInfo("generating code")
- for (dc: root.usedDataClasses) {
- var path = dc.generationTargetPath + dc.getPath
-
- // header file
- logger.logInfo("generating DataClass header '"+dc.getCppHeaderFileName+"' in '"+path+"'")
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(dc.getCppHeaderFileName, root.generateHeaderFile(dc))
-
- // source file
- logger.logInfo("generating DataClass source '"+dc.getCppSourceFileName+"' in '"+path+"'")
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(dc.getCppSourceFileName, root.generateSourceFile(dc))
-
- }
-
- }
-
- def generateHeaderFile(Root root, DataClass dc) {
- val ctor = dc.operations.filter(op|op.constructor).head
- val dtor = dc.operations.filter(op|op.destructor).head
- //TODO: getReferencedDataClasses does not contain a base class of the own package
- '''
- «generateIncludeGuardBegin(dc.path + dc.name)»
-
- «IF dc.base!=null»
- #include "«dc.base.name».h"
- «ENDIF»
- «FOR classes : root.getReferencedDataClasses(dc)»
- #include "«classes.name».h"
- «ENDFOR»
- «var models = root.getReferencedModels(dc)»
- «FOR model : models»
- «FOR classes : model.dataClasses»
- #include "«classes.path»«classes.name».h"
- «ENDFOR»
- «ENDFOR»
-
- «helpers.userCode(dc.userCode1)»
-
-
- class «dc.name»«IF dc.base!=null» : public «dc.base.name»«ENDIF» {
-
- public:
- «helpers.userCode(dc.userCode2)»
-
- «helpers.attributes(dc.attributes)»
-
- «helpers.attributeSettersGettersImplementation(dc.attributes, dc.name)»
-
- «helpers.operationsDeclaration(dc.operations, dc.name)»
-
- // default constructor, copy constructor and assignment operator
- «dc.name»();
- «dc.name»(const «dc.name»& rhs);
- «dc.name»& operator=(const «dc.name»& rhs);
-
- // constructor using fields
- «dc.name»(«dc.argList»);
-
- };
-
- «generateIncludeGuardEnd(dc.name)»
-
- '''
- }
-
- def generateSourceFile(Root root, DataClass dc) {
- val ctor = dc.operations.filter(op|op.constructor).head
- val dtor = dc.operations.filter(op|op.destructor).head
-
- '''
- /**
- * @author generated by eTrice
- *
- * Source File of DataClass «dc.name»
- */
-
- #include "«dc.getCppHeaderFileName»"
-
- «helpers.userCode(dc.userCode3)»
-
-
- // default constructor
- «dc.name»::«dc.name»()
- «IF dc.base!=null»
- :«dc.base.name»()
- «ENDIF»
- {
- «dc.attributes.attributeInitialization(false)»
- «IF ctor!=null»
- {
- // user defined constructor body
- «FOR l : ctor.detailCode.commands»
- «l»
- «ENDFOR»
- }
- «ENDIF»
- }
-
- // copy constructor
- «dc.name»::«dc.name»(const «dc.name»& rhs)
- :
- «IF dc.base!=null»
- «dc.base.name»(rhs),
- «ENDIF»
- «FOR a : dc.attributes SEPARATOR ","»
- «a.name»(rhs.«a.name»)
- «ENDFOR»
- {
- }
-
- // constructor using fields
- «dc.name»::«dc.name»(«dc.argList»)
- :
- «IF dc.base!=null»
- «dc.base.name»(«dc.base.paramList»),
- «ENDIF»
- «FOR a : dc.attributes SEPARATOR ","»
- «a.name»(«a.name»_)
- «ENDFOR»
- {
- }
-
- // assignment operator
- «dc.name»& «dc.name»::operator=(const «dc.name»& rhs)
- {
- if (this == &rhs) { return *this; };
- «IF dc.base!=null»
- «dc.base.name»::operator=(rhs);
- «ENDIF»
- «FOR a : dc.attributes»
- «a.name»= rhs.«a.name»;
- «ENDFOR»
- return *this;
- }
-
- «helpers.operationsImplementation(dc.operations, dc.name)»
-
- '''}
-
- def paramList(DataClass _dc) {
- var result = ""
- var dc = _dc
- while (dc!=null) {
- result = dc.attributes.paramList.toString + result
- dc = dc.base
- if (dc!=null)
- result = ", "+result
- }
- return result
- }
-
- def paramList(List<Attribute> attributes) {
- '''«FOR a: attributes SEPARATOR ", "»«a.name»_«ENDFOR»'''
- }
-
- def argList(DataClass _dc) {
- var result = ""
- var dc = _dc
- while (dc!=null) {
- result = dc.attributes.argListConstructor.toString + result
- dc = dc.base
- if (dc!=null)
- result = ", "+result
- }
- return result
- }
-
- def argListConstructor(List<Attribute> attributes) {
- '''«FOR a : attributes SEPARATOR ", "»«a.refType.type.typeName»«IF a.size>1»[]«ENDIF» «a.name»_«ENDFOR»'''
- }
-
-
-
- def deepCopy(DataClass _dc) {
- var result = ""
- var dc = _dc
- while (dc!=null) {
- result = deepCopy(dc.attributes).toString + result
- dc = dc.base
- }
- return result
- }
-
- def deepCopy(List<Attribute> attributes) {
- '''
- «FOR a : attributes»
- «IF a.refType.type instanceof ComplexType»
- if («a.name»!=null) {
- «IF a.size==0»
- copy.«a.name» = «a.name».deepCopy();
- «ELSE»
- for (int i=0;i<«a.name».length;i++){
- copy.«a.name»[i] = «a.name»[i].deepCopy();
- }
- «ENDIF»
- }
- «ELSE»
- «IF a.size==0»
- copy.«a.name» = «a.name»;
- «ELSE»
- for (int i=0;i<«a.name».length;i++){
- copy.«a.name»[i] = «a.name»[i];
- }
- «ENDIF»
- «ENDIF»
- «ENDFOR»
- '''
- }
-
-}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/MainGen.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/MainGen.class
deleted file mode 100644
index d991099..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/MainGen.class
+++ /dev/null
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend
deleted file mode 100644
index 61ed44a..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Henrik Rentz-Reichert (initial contribution)
- *
- *******************************************************************************/
-
-package org.eclipse.etrice.generator.cpp.gen
-
-import com.google.inject.Inject
-import com.google.inject.Singleton
-import org.eclipse.emf.ecore.resource.Resource
-import org.eclipse.etrice.generator.generic.PrepareFileSystem
-import org.eclipse.xtext.generator.IFileSystemAccess
-import org.eclipse.xtext.generator.IGenerator
-import org.eclipse.etrice.core.genmodel.etricegen.Root
-
-@Singleton
-class MainGen implements IGenerator {
-
- @Inject DataClassGen dataClassGen
- @Inject ProtocolClassGen protocolClassGen
-// @Inject ActorClassGen actorClassGen
-// @Inject SubSystemClassGen subsystemClassGen
-// @Inject SubSystemRunnerGen subsystemRunnerGen
- @Inject PrepareFileSystem prepFS
-
- override void doGenerate(Resource resource, IFileSystemAccess fsa) {
- prepFS.prepare(resource)
- for (e: resource.contents){
- if (e instanceof Root) {
- doGenerate(e as Root)
- }
- }
- }
-
- def void doGenerate(Root e) {
- dataClassGen.doGenerate(e);
- protocolClassGen.doGenerate(e);
-// actorClassGen.doGenerate(e);
-// subsystemClassGen.doGenerate(e);
-
- if (!e.library) {
-// subsystemRunnerGen.doGenerate(e);
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen$1.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen$1.class
deleted file mode 100644
index ae13d5b..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen$1.class
+++ /dev/null
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen$2.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen$2.class
deleted file mode 100644
index a9ff6f1..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen$2.class
+++ /dev/null
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.class
deleted file mode 100644
index 7212cb0..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.class
+++ /dev/null
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
deleted file mode 100644
index 240526f..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
+++ /dev/null
@@ -1,618 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Henrik Rentz-Reichert (initial contribution)
- * Thomas Schuetz (changed for C code generator)
- *
- *******************************************************************************/
-
-package org.eclipse.etrice.generator.cpp.gen
-
-import com.google.inject.Inject
-import com.google.inject.Singleton
-import org.eclipse.etrice.core.room.CommunicationType
-import org.eclipse.etrice.core.room.DataClass
-import org.eclipse.etrice.core.room.Message
-import org.eclipse.etrice.core.room.PrimitiveType
-import org.eclipse.etrice.core.room.ProtocolClass
-
-import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator
-import org.eclipse.etrice.generator.generic.ProcedureHelpers
-import org.eclipse.etrice.generator.generic.RoomExtensions
-import org.eclipse.etrice.generator.generic.TypeHelpers
-
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess
-
-import org.eclipse.etrice.core.genmodel.base.ILogger
-import org.eclipse.etrice.core.genmodel.etricegen.Root
-
-
-@Singleton
-class ProtocolClassGen extends GenericProtocolClassGenerator {
-
- @Inject extension JavaIoFileSystemAccess fileAccess
- @Inject extension CppExtensions stdExt
- @Inject extension RoomExtensions roomExt
- @Inject extension ProcedureHelpers helpers
- @Inject extension TypeHelpers
- @Inject ILogger logger
-
- def doGenerate(Root root) {
- for (pc: root.usedProtocolClasses) {
- var path = pc.generationTargetPath+pc.getPath
-
- logger.logInfo("generating ProtocolClass header '"+pc.getCppHeaderFileName+"' in '"+path+"'")
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(pc.getCppHeaderFileName, root.generateHeaderFile(pc))
-
- logger.logInfo("generating ProtocolClass source '"+pc.getCppSourceFileName+"' in '"+path+"'")
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(pc.getCppSourceFileName, root.generateSourceFile(pc))
- }
- }
-
-
- def private generateHeaderFile(Root root, ProtocolClass pc) {'''
- /**
- * @author generated by eTrice
- *
- * Header File of ProtocolClass «pc.name»
- *
- */
-
- «generateIncludeGuardBegin(pc.name)»
-
- #include "platforms/generic/etDatatypes.h"
- #include "common/modelbase/PortBase.h"
- #include "common/modelbase/InterfaceItemBase.h"
- #include "common/messaging/Address.h"
- #include "common/messaging/Message.h"
- #include <vector>
-
- namespace etRuntime {
- class IEventReceiver;
- }
-
- «helpers.userCode(pc.userCode1)»
-
- «FOR dataClass : root.getReferencedDataClasses(pc)»
- #include "«dataClass.name».h"
- «ENDFOR»
-
- class «pc.name» {
- public:
- «IF pc.commType==CommunicationType::EVENT_DRIVEN» /* message IDs */
- «genMessageIDs(pc)»
- «ELSEIF pc.commType==CommunicationType::DATA_DRIVEN»
- «ELSEIF pc.commType==CommunicationType::SYNCHRONOUS»
- #error "synchronous protocols not implemented yet"
- «ENDIF»
- «helpers.userCode(pc.userCode2)»
-
- private:
- static char* messageStrings[];
-
- public:
- char* getMessageString(int msg_id);
-
- «portClassDeclaration(pc, false)»
- «portClassDeclaration(pc, true)»
- };
- «generateIncludeGuardEnd(pc.name)»
- '''
- }
-
- def portClassDeclaration(ProtocolClass pc, Boolean conj) {
- var pclass = pc.getPortClass(conj)
- var portClassName = pc.getPortClassName(conj)
- var replPortClassName = pc.getPortClassName(conj, true)
- '''
- //------------------------------------------------------------------------------------------------------------
- // «IF conj»conjugated «ENDIF»port class
- //------------------------------------------------------------------------------------------------------------
- class «portClassName» : public etRuntime::PortBase {
- «IF pclass!=null»
- «helpers.userCode(pclass.userCode)»
- «ENDIF»
- public:
- // constructors
- «portClassName»(etRuntime::IEventReceiver actor, char* name, int localId, etRuntime::Address addr, etRuntime::Address peerAddress);
- «portClassName»(etRuntime::IEventReceiver actor, char* name, int localId, int idx, etRuntime::Address addr, etRuntime::Address peerAddress);
-
- virtual void receive(etRuntime::Message m);
- «IF pclass!=null»
- «helpers.attributes(pclass.attributes)»
- «helpers.operationsDeclaration(pclass.operations, portClassName)»
- «ENDIF»
-
- // sent messages
- «FOR m : pc.getOutgoing(conj)»
- «sendMessageDeclaration(m,conj)»
- «ENDFOR»
- };
-
- //------------------------------------------------------------------------------------------------------------
- // «IF conj»conjugated «ENDIF»replicated port class
- //------------------------------------------------------------------------------------------------------------
- class «replPortClassName» {
- private:
- std::vector<«portClassName»> ports;
- int replication;
-
- public:
- // constructor
- «replPortClassName»(etRuntime::IEventReceiver actor, char* name, int localId, std::vector<etRuntime::Address> addr, std::vector<etRuntime::Address> peerAddress);
-
- int getReplication() { return replication; }
- int getIndexOf(const etRuntime::InterfaceItemBase& ifitem){ return ifitem.getIdx(); }
- «portClassName» get(int i) {return ports[i];}
-
- «IF pc.commType==CommunicationType::EVENT_DRIVEN»
- «IF conj»
- // incoming messages
-
- «FOR m : pc.getAllIncomingMessages()» «messageSignature(m)»;
- «ENDFOR»
- «ELSE»
- // outgoing messages
- «FOR m : pc.getAllOutgoingMessages()» «messageSignature(m)»;
- «ENDFOR»
- «ENDIF»
- «ELSEIF pc.commType==CommunicationType::DATA_DRIVEN»
- /*--------------------- port structs and methods */
- «pc.genDataDrivenPortHeaders»
- «ELSEIF pc.commType==CommunicationType::SYNCHRONOUS»
- #error "synchronous protocols not implemented yet"
- «ENDIF»
-
- };
- '''
- }
-
- def portClassImplementation(ProtocolClass pc, Boolean conj) {
- var pclass = pc.getPortClass(conj)
- var portClassName = pc.getPortClassName(conj)
- var replPortClassName = pc.getPortClassName(conj, true)
- '''
- «pc.name»::«portClassName»::«portClassName»(IEventReceiver actor, char* name, int localId, Address addr, Address peerAddress)
- : PortBase(actor, name, localId, 0, addr, peerAddress)
- {
- DebuggingService::getInstance().addPortInstance(*this);
- }
-
- «pc.name»::«portClassName»::«portClassName»(IEventReceiver actor, char* name, int localId, int idx, Address addr, Address peerAddress)
- : PortBase(actor, name, localId, idx, addr, peerAddress)
- {
- DebuggingService::getInstance().addPortInstance(*this);
- }
-
- void «pc.name»::«portClassName»::receive(Message msg) {
- //if (!(m instanceof EventMessage)) return;
- //EventMessage msg = (EventMessage) m;
- if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)
- printf("unknown");
- else {
- if (messageStrings[msg.getEvtId()] != "timerTick"){
-««« TODOTS: model switch for activation
- DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
- }
- }
- «IF pc.handlesReceive(conj)»
- switch (msg.getEvtId()) {
- «FOR hdlr : pc.getReceiveHandlers(conj)»
- case «hdlr.msg.getCodeName()»:
- {
- «FOR command : hdlr.detailCode.commands»
- «command»
- «ENDFOR»
- }
- break;
- «ENDFOR»
- default:
- «ENDIF» getActor().receiveEvent(*this, msg.getEvtId(), msg.getData());
- «IF pc.handlesReceive(conj)»
- }
- «ENDIF»
- }
- «IF pclass!=null»
- «helpers.operationsImplementation(pclass.operations, portClassName)»
- «ENDIF»
-
- // sent messages
- «FOR m : pc.getOutgoing(conj)»
- «sendMessage(m, pc.name + "::" + portClassName, conj)»
- «ENDFOR»
-
- //-------------------------------------------------------------------------------
- // replicated port class
- //-------------------------------------------------------------------------------
- «pc.name»::«replPortClassName»::«replPortClassName»(IEventReceiver actor, char* name, int localId, std::vector<Address> addr, std::vector<Address> peerAddress) {
- int replication = addr.size();
- ports = new std::vector<«pc.name»::«portClassName»>(replication);
- for (int i=0; i<replication; ++i) {
- ports[i] = new «pc.name»::«portClassName»(actor, name+i, localId, i, addr[i], peerAddress[i]);
- }
- }
-
- «IF conj»
- // incoming messages
- «FOR m : pc.getAllIncomingMessages()»
- «messageSignatureDefinition(m, pc.name + "::" + replPortClassName)»{
- for (int i=0; i<replication; ++i) {
- ports[i].«messageCall(m)»;
- }
- }
- «ENDFOR»
- «ELSE»
- // outgoing messages
- «FOR m : pc.getAllOutgoingMessages()»
- «messageSignatureDefinition(m, pc.name + "::" + replPortClassName)»{
- for (int i=0; i<replication; ++i) {
- ports[i].«messageCall(m)»;
- }
- }
- «ENDFOR»
- «ENDIF»
- '''
- }
-
- def private generateSourceFile(Root root, ProtocolClass pc) {'''
- /**
- * @author generated by eTrice
- *
- * Source File of ProtocolClass «pc.name»
- *
- */
-
- #include "«pc.getCppHeaderFileName»"
- #include "common/debugging/DebuggingService.h"
- #include <stdio.h>
-
- using namespace etRuntime;
-
- «helpers.userCode(pc.userCode3)»
-
- «IF pc.commType==CommunicationType::EVENT_DRIVEN»
-
- //----------------------------------------------
- // java code
- //----------------------------------------------
-
- «helpers.userCode(pc.userCode2)»
-
- char* «pc.name»::messageStrings[] = {"MIN", «FOR m : pc.getAllOutgoingMessages()»"«m.name»",«ENDFOR» «FOR m : pc.getAllIncomingMessages()»"«m.name»",«ENDFOR»"MAX"};
-
- char* «pc.name»::getMessageString(int msg_id) {
- if (msg_id<MSG_MIN || msg_id>MSG_MAX+1){
- // id out of range
- return "Message ID out of range";
- }
- else{
- return messageStrings[msg_id];
- }
- }
-
- «portClassImplementation(pc, false)»
- «portClassImplementation(pc, true)»
-
- /*--------------------- debug helpers */
- «generateDebugHelpersImplementation(root, pc)»
- «ELSEIF pc.commType==CommunicationType::DATA_DRIVEN»
- «pc.genDataDrivenPortSources»
- «ELSEIF pc.commType==CommunicationType::SYNCHRONOUS»
- #error "synchronoue protocols not implemented yet"
- «ENDIF»
-
-
- '''
- }
-
- def private portClassHeader(ProtocolClass pc, Boolean conj){
- var portClassName = pc.getPortClassName(conj)
- var replPortClassName = pc.getPortClassName(conj, true)
- var messages = if (conj) pc.allIncomingMessages else pc.allOutgoingMessages
-
- '''
- typedef etPort «portClassName»;
- typedef etReplPort «replPortClassName»;
-
- «IF pc.getPortClass(conj)!=null»
- «IF !(pc.getPortClass(conj).attributes.empty)»
-/* variable part of PortClass (RAM) */
-typedef struct «portClassName»_var «portClassName»_var;
-struct «portClassName»_var {
- «helpers.attributes(pc.getPortClass(conj).attributes)»
- };
- «FOR a:pc.getPortClass(conj).attributes»
- «IF a.defaultValueLiteral!=null»
- «logger.logInfo(portClassName+" "+a.name+": Attribute initialization not supported in C")»
- «ENDIF»
- «ENDFOR»
- «ENDIF»
- «ENDIF»
-
- «FOR message : messages»
- «var hasData = message.data!=null»
- «var typeName = if (hasData) message.data.refType.type.typeName else ""»
- «var refp = if (hasData && (!(message.data.refType.type instanceof PrimitiveType)||(message.data.refType.ref))) "*" else ""»
- «var data = if (hasData) ", "+typeName+refp+" data" else ""»
- «messageSignature(portClassName, message.name, "", data)»;
- «messageSignature(replPortClassName, message.name, "_broadcast", data)»;
- «messageSignature(replPortClassName, message.name, "", ", int idx"+data)»;
- «ENDFOR»
-
- «IF (pc.getPortClass(conj) != null)»
- «helpers.operationsDeclaration(pc.getPortClass(conj).operations, portClassName)»
- «helpers.operationsDeclaration(pc.getPortClass(conj).operations, replPortClassName)»
- «ENDIF»
-
- «IF pc.handlesReceive(conj)»
- «FOR h:getReceiveHandlers(pc,conj)»
-void «portClassName»_«h.msg.name»_receiveHandler(«portClassName»* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc);
- «ENDFOR»
- «ENDIF»
- '''
- }
-
-
-
- def private genDataDrivenPortHeaders(ProtocolClass pc) {
- var sentMsgs = pc.allIncomingMessages.filter(m|m.data!=null)
-
- '''
- /* data driven send port (conjugated) */
- typedef struct {
- «FOR msg : sentMsgs»
- «var typeName = msg.data.refType.type.typeName»
- «var refp = if (msg.data.refType.ref) "*" else ""»
- «typeName»«refp» «msg.name»;
- «ENDFOR»
- }
- «pc.getPortClassName(true)»;
-
- /* data driven receive port (regular) */
- typedef struct {
- const «pc.getPortClassName(true)»* peer;
- }
- «pc.getPortClassName(false)»;
-
- «FOR message : sentMsgs»
- «var hasData = message.data!=null»
- «var typeName = if (hasData) message.data.refType.type.typeName else ""»
- «var refp = if (hasData && !(message.data.refType.type instanceof PrimitiveType)) "*" else ""»
- «var data = if (hasData) ", "+typeName+refp+" data" else ""»
- «messageSetterSignature(pc.getPortClassName(true), message.name, data)»;
- «messageGetterSignature(pc.getPortClassName(false), message.name, typeName)»;
-
- «ENDFOR»
- '''
- }
- def private genDataDrivenPortSources(ProtocolClass pc) {
- var messages = pc.allIncomingMessages.filter(m|m.data!=null)
- '''
- «FOR message : messages»
- «var typeName =message.data.refType.type.typeName»
- «var refp = if (!(message.data.refType.type instanceof PrimitiveType)) "*" else ""»
- «var refa = if ((message.data.refType.type instanceof PrimitiveType)) "&" else ""»
- «var data = ", "+typeName+refp+" data"»
- «messageSetterSignature(pc.getPortClassName(true), message.name, data)» {
- self->«message.name» = data;
- }
- «messageGetterSignature(pc.getPortClassName(false), message.name, typeName)» {
- return self->peer->«message.name»;
- }
-
- «ENDFOR»
- '''
- }
-
- def private portClassSource(ProtocolClass pc, Boolean conj){
- var portClassName = pc.getPortClassName(conj)
- var replPortClassName = pc.getPortClassName(conj, true)
- var messages = if (conj) pc.allIncomingMessages else pc.allOutgoingMessages
- var dir = if (conj) "IN_" else "OUT_"
-
- '''
- «FOR message : messages»
- «var hasData = message.data!=null»
- «var typeName = if (hasData) message.data.refType.type.typeName else ""»
- «var refp = if (hasData && ((message.data.refType.ref))) "*" else ""»
- «var refpd = if (hasData && (!(message.data.refType.type instanceof PrimitiveType)||(message.data.refType.ref))) "*" else ""»
- «var refa = if (hasData && (!(message.data.refType.type instanceof PrimitiveType))&&(!(message.data.refType.ref))) "" else "&"»
- «var data = if (hasData) ", "+typeName+refpd+" data" else ""»
- «var dataCall = if (hasData) ", data" else ""»
- «var hdlr = message.getSendHandler(conj)»
-
- «messageSignature(portClassName, message.name, "", data)» {
- «IF hdlr != null»
- «FOR command : hdlr.detailCode.commands» «command»
- «ENDFOR»
- «ELSE»
- ET_MSC_LOGGER_SYNC_ENTRY("«portClassName»", "«message.name»")
- «sendMessageCall(hasData, "self", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
- ET_MSC_LOGGER_SYNC_EXIT
- «ENDIF»
- }
-
- «messageSignature(replPortClassName, message.name, "_broadcast", data)» {
- «IF hdlr != null»
- int i;
- for (i=0; i<((etReplPort*)self)->size; ++i) {
- «portClassName»_«message.name»((etPort*)&((etReplPort*)self)->ports[i]«dataCall»);
- }
- «ELSE»
- int i;
- ET_MSC_LOGGER_SYNC_ENTRY("«replPortClassName»", "«message.name»")
- for (i=0; i<((etReplPort*)self)->size; ++i) {
- «sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[i])", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
- }
- ET_MSC_LOGGER_SYNC_EXIT
- «ENDIF»
- }
-
- «messageSignature(replPortClassName, message.name, "", ", int idx"+data)» {
- «IF hdlr != null»
- «portClassName»_«message.name»((etPort*)&((etReplPort*)self)->ports[idx]«dataCall»);
- «ELSE»
- ET_MSC_LOGGER_SYNC_ENTRY("«replPortClassName»", "«message.name»")
- if (0<=idx && idx<((etReplPort*)self)->size) {
- «sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[idx])", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
- }
- ET_MSC_LOGGER_SYNC_EXIT
- «ENDIF»
- }
- «ENDFOR»
-
- «IF (pc.getPortClass(conj) != null)»
- «helpers.operationsImplementation(pc.getPortClass(conj).operations, portClassName)»
- «helpers.operationsImplementation(pc.getPortClass(conj).operations, replPortClassName)»
- «ENDIF»
-
- // getReplication
- etInt32 «replPortClassName»_getReplication(const «replPortClassName»* self) {
- return ((etReplPort*)self)->size;
- }
-
- «IF pc.handlesReceive(conj)»
- «genReceiveHandlers(pc,conj)»
- «ENDIF»
-
- '''
- }
-
- def private sendMessageCall(boolean hasData, String self, String msg, String typeName, String data) {
- if (hasData)
- "etPort_sendMessage("+self+", "+msg+", sizeof("+typeName+"), "+data+");"
- else
- "etPort_sendMessage("+self+", "+msg+", 0, NULL);"
- }
-
- def private messageSignature(String className, String messageName, String methodSuffix, String data) {
- "void "+className+"_"+messageName+methodSuffix+"(const "+className+"* self"+data+")"
- }
-
- def private messageSetterSignature(String className, String messageName, String data) {
- "void "+className+"_"+messageName+"_set("+className+"* self"+data+")"
- }
-
- def private messageGetterSignature(String className, String messageName, String type) {
- type+" "+className+"_"+messageName+"_get(const "+className+"* const self)"
- }
-
- def private messageCall(Message m) {'''
- «m.name»(«IF m.data!=null» «m.data.name»«ENDIF»)
- '''}
-
-// def sendMessage(Message m, boolean conj) {'''
-// «var dir = if (conj) "IN" else "OUT"»
-// «var hdlr = m.getSendHandler(conj)»
-// «messageSignature(m)»{
-// if (getPeerAddress()!= 0)
-// «IF m.data==null»getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), «dir»_«m.name»));
-// «ELSE»getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), «dir»_«m.name», «m.data.name»«IF (!m.data.ref)».deepCopy()«ENDIF»));
-// «ENDIF»
-// }
-// '''
-// }
-
- def private genReceiveHandlers(ProtocolClass pc, Boolean conj){
- var portClassName = pc.getPortClassName(conj)
- var replPortClassName = pc.getPortClassName(conj, true)
-
- '''
- /* receiver handlers */
- «FOR h:getReceiveHandlers(pc,conj)»
- void «portClassName»_«h.msg.name»_receiveHandler(«portClassName»* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){
- «userCode(h.detailCode)»
- /* hand over the message to the actor: */
- /* (*receiveMessageFunc)(actor, self, msg); */
- }
- «ENDFOR»
- '''}
-
-
-
- def private generateDebugHelpersImplementation(Root root, ProtocolClass pc){'''
-
-««« TODO: make this optional or different for smaller footprint
- /* message names as strings for debugging (generate MSC) */
- static const char* «pc.name»_messageStrings[] = {"MIN", «FOR m : pc.getAllOutgoingMessages()»"«m.name»",«ENDFOR»«FOR m : pc.getAllIncomingMessages()»"«m.name»", «ENDFOR»"MAX"};
-
- const char* «pc.name»_getMessageString(int msg_id) {
- if (msg_id < «pc.name»::MSG_MIN || msg_id > «pc.name»::MSG_MAX+1){
- /* id out of range */
- return "Message ID out of range";
- }
- else{
- return «pc.name»_messageStrings[msg_id];
- }
- }
- '''
- }
-
- //----------------------------------------------------
- // from java generator
- //---------------------------------------------------
- def messageSignature(Message m) {
- '''«IF m.priv»private:«ELSE»public:«ENDIF» void «m.name»(«IF m.data!=null»«m.data.refType.type.typeName» «m.data.name»«ENDIF»)'''
- }
-
- def messageSignatureExplicit(Message m) {
- var dc = (m.data.refType.type as DataClass)
- '''public: void «m.name»(«IF dc.base!=null»«dc.base.typeName» _super, «ENDIF»«FOR a : dc.attributes SEPARATOR ", "»«a.refType.type.typeName»«IF a.size>1»[]«ENDIF» «a.name»«ENDFOR»)'''
- }
-
- def messageSignatureDefinition(Message m, String classPrefix) {
- '''void «classPrefix»::«m.name»(«IF m.data!=null»«m.data.refType.type.typeName» «m.data.name»«ENDIF»)'''
- }
-
- def messageSignatureExplicitDefinition(Message m, String classPrefix) {
- var dc = (m.data.refType.type as DataClass)
- '''void «classPrefix»::«m.name»(«IF dc.base!=null»«dc.base.typeName» _super, «ENDIF»«FOR a : dc.attributes SEPARATOR ", "»«a.refType.type.typeName»«IF a.size>1»[]«ENDIF» «a.name»«ENDFOR»)'''
- }
-
-// def messageCall(Message m) {
-// '''«m.name»(«IF m.data!=null» «m.data.name»«ENDIF»)'''
-// }
-
- def sendMessageDeclaration(Message m, boolean conj) {
- '''
- «messageSignature(m)»;
- «IF m.data!=null && m.data.refType.type instanceof DataClass»
- «messageSignatureExplicit(m)»;
- «ENDIF»
- '''
- }
- def sendMessage(Message m, String classPrefix, boolean conj) {
- var dir = if (conj) "IN" else "OUT"
- var hdlr = m.getSendHandler(conj)
- '''
- «messageSignatureDefinition(m, classPrefix)» {
- «IF hdlr!=null»
- «FOR command : hdlr.detailCode.commands» «command»
- «ENDFOR»
- «ELSE»
- if (messageStrings[ «dir»_«m.name»] != "timerTick"){
-««« TODOTS: model switch for activation
- DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[«dir»_«m.name»]);
- }
- if (getPeerAddress().isValid()){
- «IF m.data==null»getPeerMsgReceiver().receive(new Message(getPeerAddress(), «dir»_«m.name»));
- «ELSE»getPeerMsgReceiver().receive(new Message(getPeerAddress(), «dir»_«m.name», reinterpret_cast<void*>(«IF (m.data.refType.ref && !(m.data.refType.type instanceof PrimitiveType))»&«ENDIF»«m.data.name»)));
- «ENDIF»
- }
- «ENDIF»
- }
- «IF m.data!=null && m.data.refType.type instanceof DataClass»
- «messageSignatureExplicitDefinition(m, classPrefix)» {
- «m.name»(new «m.data.refType.type.name»(«IF (m.data.refType.type as DataClass).base!=null»_super, «ENDIF»«FOR a : (m.data.refType.type as DataClass).attributes SEPARATOR ", "»«a.name»«ENDFOR»));
- }
- «ENDIF»
- '''
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/setup/GeneratorModule.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/setup/GeneratorModule.class
deleted file mode 100644
index 72df407..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/setup/GeneratorModule.class
+++ /dev/null
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
deleted file mode 100644
index c0adff9..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
+++ /dev/null
@@ -1,170 +0,0 @@
-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.generator.generic.AbstractTransitionChainGenerator;
-import org.eclipse.etrice.generator.generic.ILanguageExtension;
-import org.eclipse.xtext.util.Pair;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class CppExtensions implements ILanguageExtension {
- @Inject
- private AbstractTransitionChainGenerator chainGenerator;
-
- public String getTypedDataDefinition(final Message m) {
- String _generateTypedData = this.chainGenerator.generateTypedData(m);
- return _generateTypedData;
- }
-
- public String getCppHeaderFileName(final RoomClass rc) {
- String _name = rc.getName();
- String _operator_plus = StringExtensions.operator_plus(_name, ".h");
- return _operator_plus;
- }
-
- public String getCppSourceFileName(final RoomClass rc) {
- String _name = rc.getName();
- String _operator_plus = StringExtensions.operator_plus(_name, ".cpp");
- return _operator_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 _operator_plus = StringExtensions.operator_plus(namespace, ".");
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, member);
- return _operator_plus_1;
- }
-
- public boolean usesInheritance() {
- return true;
- }
-
- public String genEnumeration(final String name, final List<Pair<String,String>> entries) {
- StringConcatenation _builder = new StringConcatenation();
- {
- for(final Pair<String,String> entry : entries) {
- _builder.append("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)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 _operator_plus = StringExtensions.operator_plus(type, " ");
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, name);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "[]");
- return _operator_plus_2;
- }
-
- public String constructorName(final String cls) {
- return cls;
- }
-
- public String destructorName(final String cls) {
- String _operator_plus = StringExtensions.operator_plus(cls, "_dtor");
- return _operator_plus;
- }
-
- public String constructorReturnType() {
- return "";
- }
-
- public String destructorReturnType() {
- return "void";
- }
-
- public StringConcatenation 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 StringConcatenation generateIncludeGuardBegin(final String filename) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("#ifndef ");
- StringConcatenation _includeGuardString = this.getIncludeGuardString(filename);
- _builder.append(_includeGuardString, "");
- _builder.newLineIfNotEmpty();
- _builder.append("#define ");
- StringConcatenation _includeGuardString_1 = this.getIncludeGuardString(filename);
- _builder.append(_includeGuardString_1, "");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public StringConcatenation generateIncludeGuardEnd(final String filename) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("#endif /* ");
- StringConcatenation _includeGuardString = this.getIncludeGuardString(filename);
- _builder.append(_includeGuardString, "");
- _builder.append(" */");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java
deleted file mode 100644
index 967c1fc..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java
+++ /dev/null
@@ -1,750 +0,0 @@
-package org.eclipse.etrice.generator.cpp.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.HashSet;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.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.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.ComparableExtensions;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-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 _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- String path = _operator_plus;
- String _cppHeaderFileName = this.stdExt.getCppHeaderFileName(dc);
- String _operator_plus_1 = StringExtensions.operator_plus("generating DataClass header \'", _cppHeaderFileName);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
- this.logger.logInfo(_operator_plus_4);
- this.fileAccess.setOutputPath(path);
- String _cppHeaderFileName_1 = this.stdExt.getCppHeaderFileName(dc);
- StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, dc);
- this.fileAccess.generateFile(_cppHeaderFileName_1, _generateHeaderFile);
- String _cppSourceFileName = this.stdExt.getCppSourceFileName(dc);
- String _operator_plus_5 = StringExtensions.operator_plus("generating DataClass source \'", _cppSourceFileName);
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
- String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
- this.logger.logInfo(_operator_plus_8);
- this.fileAccess.setOutputPath(path);
- String _cppSourceFileName_1 = this.stdExt.getCppSourceFileName(dc);
- StringConcatenation _generateSourceFile = this.generateSourceFile(root, dc);
- this.fileAccess.generateFile(_cppSourceFileName_1, _generateSourceFile);
- }
- }
- }
-
- public StringConcatenation generateHeaderFile(final Root root, final DataClass dc) {
- StringConcatenation _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)_isConstructor);
- }
- };
- Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
- StandardOperation _head = IterableExtensions.<StandardOperation>head(_filter);
- final StandardOperation ctor = _head;
- 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)_isDestructor);
- }
- };
- Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_1);
- StandardOperation _head_1 = IterableExtensions.<StandardOperation>head(_filter_1);
- final StandardOperation dtor = _head_1;
- StringConcatenation _builder = new StringConcatenation();
- String _path = this.roomExt.getPath(dc);
- String _name = dc.getName();
- String _operator_plus = StringExtensions.operator_plus(_path, _name);
- StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_operator_plus);
- _builder.append(_generateIncludeGuardBegin, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- DataClass _base = dc.getBase();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
- if (_operator_notEquals) {
- _builder.append("#include \"");
- DataClass _base_1 = dc.getBase();
- String _name_1 = _base_1.getName();
- _builder.append(_name_1, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(dc);
- for(final DataClass classes : _referencedDataClasses) {
- _builder.append("#include \"");
- String _name_2 = classes.getName();
- _builder.append(_name_2, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- EList<RoomModel> _referencedModels = root.getReferencedModels(dc);
- EList<RoomModel> models = _referencedModels;
- _builder.newLineIfNotEmpty();
- {
- 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();
- StringConcatenation _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 _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_base_2, null);
- if (_operator_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();
- StringConcatenation _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();
- StringConcatenation _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();
- StringConcatenation _attributeSettersGettersImplementation = this.helpers.attributeSettersGettersImplementation(_attributes_2, _name_6);
- _builder.append(_attributeSettersGettersImplementation, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- EList<StandardOperation> _operations_2 = dc.getOperations();
- String _name_7 = dc.getName();
- StringConcatenation _operationsDeclaration = this.helpers.operationsDeclaration(_operations_2, _name_7);
- _builder.append(_operationsDeclaration, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// default constructor, 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();
- StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_14);
- _builder.append(_generateIncludeGuardEnd, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public StringConcatenation generateSourceFile(final Root root, final DataClass dc) {
- StringConcatenation _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)_isConstructor);
- }
- };
- Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
- StandardOperation _head = IterableExtensions.<StandardOperation>head(_filter);
- final StandardOperation ctor = _head;
- 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)_isDestructor);
- }
- };
- Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_1);
- StandardOperation _head_1 = IterableExtensions.<StandardOperation>head(_filter_1);
- final StandardOperation dtor = _head_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();
- StringConcatenation _userCode = this.helpers.userCode(_userCode3);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.newLine();
- _builder.append("// default constructor");
- _builder.newLine();
- String _name_1 = dc.getName();
- _builder.append(_name_1, "");
- _builder.append("::");
- String _name_2 = dc.getName();
- _builder.append(_name_2, "");
- _builder.append("() ");
- _builder.newLineIfNotEmpty();
- {
- DataClass _base = dc.getBase();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
- if (_operator_notEquals) {
- _builder.append("\t");
- _builder.append(":");
- DataClass _base_1 = dc.getBase();
- String _name_3 = _base_1.getName();
- _builder.append(_name_3, " ");
- _builder.append("()");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- EList<Attribute> _attributes = dc.getAttributes();
- StringConcatenation _attributeInitialization = this.helpers.attributeInitialization(_attributes, false);
- _builder.append(_attributeInitialization, " ");
- _builder.newLineIfNotEmpty();
- {
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(ctor, null);
- if (_operator_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 _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_base_2, null);
- if (_operator_notEquals_2) {
- _builder.append("\t");
- DataClass _base_3 = dc.getBase();
- String _name_7 = _base_3.getName();
- _builder.append(_name_7, " ");
- _builder.append("(rhs),");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<Attribute> _attributes_1 = dc.getAttributes();
- boolean hasAnyElements = false;
- for(final Attribute a : _attributes_1) {
- if (!hasAnyElements) {
- hasAnyElements = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t");
- String _name_8 = a.getName();
- _builder.append(_name_8, " ");
- _builder.append("(rhs.");
- String _name_9 = a.getName();
- _builder.append(_name_9, " ");
- _builder.append(")");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("{");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("// constructor using fields");
- _builder.newLine();
- String _name_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 _operator_notEquals_3 = ObjectExtensions.operator_notEquals(_base_4, null);
- if (_operator_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 hasAnyElements_1 = false;
- for(final Attribute a_1 : _attributes_2) {
- if (!hasAnyElements_1) {
- hasAnyElements_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 _operator_notEquals_4 = ObjectExtensions.operator_notEquals(_base_7, null);
- if (_operator_notEquals_4) {
- _builder.append("\t");
- DataClass _base_8 = dc.getBase();
- String _name_18 = _base_8.getName();
- _builder.append(_name_18, " ");
- _builder.append("::operator=(rhs);");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<Attribute> _attributes_3 = dc.getAttributes();
- for(final Attribute a_2 : _attributes_3) {
- _builder.append("\t");
- String _name_19 = a_2.getName();
- _builder.append(_name_19, " ");
- _builder.append("= rhs.");
- String _name_20 = a_2.getName();
- _builder.append(_name_20, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("return *this;");
- _builder.newLine();
- _builder.append("}\t\t\t");
- _builder.newLine();
- _builder.newLine();
- EList<StandardOperation> _operations_2 = dc.getOperations();
- String _name_21 = dc.getName();
- StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations_2, _name_21);
- _builder.append(_operationsImplementation, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public String paramList(final DataClass _dc) {
- String result = "";
- DataClass dc = _dc;
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(dc, null);
- Boolean _xwhileexpression = _operator_notEquals;
- while (_xwhileexpression) {
- {
- EList<Attribute> _attributes = dc.getAttributes();
- StringConcatenation _paramList = this.paramList(_attributes);
- String _string = _paramList.toString();
- String _operator_plus = StringExtensions.operator_plus(_string, result);
- result = _operator_plus;
- DataClass _base = dc.getBase();
- dc = _base;
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(dc, null);
- if (_operator_notEquals_1) {
- String _operator_plus_1 = StringExtensions.operator_plus(", ", result);
- result = _operator_plus_1;
- }
- }
- boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(dc, null);
- _xwhileexpression = _operator_notEquals_2;
- }
- return result;
- }
-
- public StringConcatenation paramList(final List<Attribute> attributes) {
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean hasAnyElements = false;
- for(final Attribute a : attributes) {
- if (!hasAnyElements) {
- hasAnyElements = 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 _operator_notEquals = ObjectExtensions.operator_notEquals(dc, null);
- Boolean _xwhileexpression = _operator_notEquals;
- while (_xwhileexpression) {
- {
- EList<Attribute> _attributes = dc.getAttributes();
- StringConcatenation _argListConstructor = this.argListConstructor(_attributes);
- String _string = _argListConstructor.toString();
- String _operator_plus = StringExtensions.operator_plus(_string, result);
- result = _operator_plus;
- DataClass _base = dc.getBase();
- dc = _base;
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(dc, null);
- if (_operator_notEquals_1) {
- String _operator_plus_1 = StringExtensions.operator_plus(", ", result);
- result = _operator_plus_1;
- }
- }
- boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(dc, null);
- _xwhileexpression = _operator_notEquals_2;
- }
- return result;
- }
-
- public StringConcatenation argListConstructor(final List<Attribute> attributes) {
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean hasAnyElements = false;
- for(final Attribute a : attributes) {
- if (!hasAnyElements) {
- hasAnyElements = true;
- } else {
- _builder.appendImmediate(", ", "");
- }
- RefableType _refType = a.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this.typeHelpers.typeName(_type);
- _builder.append(_typeName, "");
- {
- int _size = a.getSize();
- boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)1));
- if (_operator_greaterThan) {
- _builder.append("[]");
- }
- }
- _builder.append(" ");
- String _name = a.getName();
- _builder.append(_name, "");
- _builder.append("_");
- }
- }
- return _builder;
- }
-
- public String deepCopy(final DataClass _dc) {
- String result = "";
- DataClass dc = _dc;
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(dc, null);
- Boolean _xwhileexpression = _operator_notEquals;
- while (_xwhileexpression) {
- {
- EList<Attribute> _attributes = dc.getAttributes();
- StringConcatenation _deepCopy = this.deepCopy(_attributes);
- String _string = _deepCopy.toString();
- String _operator_plus = StringExtensions.operator_plus(_string, result);
- result = _operator_plus;
- DataClass _base = dc.getBase();
- dc = _base;
- }
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(dc, null);
- _xwhileexpression = _operator_notEquals_1;
- }
- return result;
- }
-
- public StringConcatenation 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 _operator_equals = ObjectExtensions.operator_equals(((Integer)_size), ((Integer)0));
- if (_operator_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 _operator_equals_1 = ObjectExtensions.operator_equals(((Integer)_size_1), ((Integer)0));
- if (_operator_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
deleted file mode 100644
index 177f6e7..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.eclipse.etrice.generator.cpp.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.etrice.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.generator.cpp.gen.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;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-
-@SuppressWarnings("all")
-@Singleton
-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 _operator_not = BooleanExtensions.operator_not(_isLibrary);
- if (_operator_not) {
- }
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java
deleted file mode 100644
index efb4764..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java
+++ /dev/null
@@ -1,2207 +0,0 @@
-package org.eclipse.etrice.generator.cpp.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.HashSet;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.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.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-import org.eclipse.xtext.xbase.lib.ComparableExtensions;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class ProtocolClassGen extends GenericProtocolClassGenerator {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private CppExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @Inject
- private TypeHelpers _typeHelpers;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<ProtocolClass> _usedProtocolClasses = root.getUsedProtocolClasses();
- for (final ProtocolClass pc : _usedProtocolClasses) {
- {
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(pc);
- String _path = this.roomExt.getPath(pc);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- String path = _operator_plus;
- String _cppHeaderFileName = this.stdExt.getCppHeaderFileName(pc);
- String _operator_plus_1 = StringExtensions.operator_plus("generating ProtocolClass header \'", _cppHeaderFileName);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
- this.logger.logInfo(_operator_plus_4);
- this.fileAccess.setOutputPath(path);
- String _cppHeaderFileName_1 = this.stdExt.getCppHeaderFileName(pc);
- StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, pc);
- this.fileAccess.generateFile(_cppHeaderFileName_1, _generateHeaderFile);
- String _cppSourceFileName = this.stdExt.getCppSourceFileName(pc);
- String _operator_plus_5 = StringExtensions.operator_plus("generating ProtocolClass source \'", _cppSourceFileName);
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
- String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
- this.logger.logInfo(_operator_plus_8);
- this.fileAccess.setOutputPath(path);
- String _cppSourceFileName_1 = this.stdExt.getCppSourceFileName(pc);
- StringConcatenation _generateSourceFile = this.generateSourceFile(root, pc);
- this.fileAccess.generateFile(_cppSourceFileName_1, _generateSourceFile);
- }
- }
- }
-
- private StringConcatenation generateHeaderFile(final Root root, final ProtocolClass pc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Header File of ProtocolClass ");
- String _name = pc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- String _name_1 = pc.getName();
- StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
- _builder.append(_generateIncludeGuardBegin, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include \"platforms/generic/etDatatypes.h\"");
- _builder.newLine();
- _builder.append("#include \"common/modelbase/PortBase.h\"");
- _builder.newLine();
- _builder.append("#include \"common/modelbase/InterfaceItemBase.h\"");
- _builder.newLine();
- _builder.append("#include \"common/messaging/Address.h\"");
- _builder.newLine();
- _builder.append("#include \"common/messaging/Message.h\"");
- _builder.newLine();
- _builder.append("#include <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();
- StringConcatenation _userCode = this.helpers.userCode(_userCode1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(pc);
- for(final DataClass dataClass : _referencedDataClasses) {
- _builder.append("#include \"");
- String _name_2 = dataClass.getName();
- _builder.append(_name_2, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("class ");
- String _name_3 = pc.getName();
- _builder.append(_name_3, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("public:");
- _builder.newLine();
- {
- CommunicationType _commType = pc.getCommType();
- boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.EVENT_DRIVEN);
- if (_operator_equals) {
- _builder.append("\t /* message IDs */");
- _builder.newLineIfNotEmpty();
- _builder.append("\t ");
- String _genMessageIDs = this.genMessageIDs(pc);
- _builder.append(_genMessageIDs, " ");
- _builder.newLineIfNotEmpty();
- } else {
- CommunicationType _commType_1 = pc.getCommType();
- boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, CommunicationType.DATA_DRIVEN);
- if (_operator_equals_1) {
- } else {
- CommunicationType _commType_2 = pc.getCommType();
- boolean _operator_equals_2 = ObjectExtensions.operator_equals(_commType_2, CommunicationType.SYNCHRONOUS);
- if (_operator_equals_2) {
- _builder.append("#error \"synchronous protocols not implemented yet\"");
- _builder.newLine();
- }
- }
- }
- }
- _builder.append("\t\t");
- DetailCode _userCode2 = pc.getUserCode2();
- StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append(" ");
- _builder.append("private:");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("static char* messageStrings[];");
- _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");
- StringConcatenation _portClassDeclaration = this.portClassDeclaration(pc, ((Boolean)false));
- _builder.append(_portClassDeclaration, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- StringConcatenation _portClassDeclaration_1 = this.portClassDeclaration(pc, ((Boolean)true));
- _builder.append(_portClassDeclaration_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("};");
- _builder.newLine();
- String _name_4 = pc.getName();
- StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_4);
- _builder.append(_generateIncludeGuardEnd, "");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public StringConcatenation portClassDeclaration(final ProtocolClass pc, final Boolean conj) {
- StringConcatenation _xblockexpression = null;
- {
- PortClass _portClass = this.roomExt.getPortClass(pc, conj);
- PortClass pclass = _portClass;
- String _portClassName = this.roomExt.getPortClassName(pc, conj);
- String portClassName = _portClassName;
- String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
- String replPortClassName = _portClassName_1;
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("//------------------------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.append("// ");
- {
- if (conj) {
- _builder.append("conjugated ");
- }
- }
- _builder.append("port class");
- _builder.newLineIfNotEmpty();
- _builder.append("//------------------------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.append("class ");
- _builder.append(portClassName, "");
- _builder.append(" : public etRuntime::PortBase {");
- _builder.newLineIfNotEmpty();
- {
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(pclass, null);
- if (_operator_notEquals) {
- _builder.append("\t");
- DetailCode _userCode = pclass.getUserCode();
- StringConcatenation _userCode_1 = this.helpers.userCode(_userCode);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append(" ");
- _builder.append("public:");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// constructors");
- _builder.newLine();
- _builder.append("\t ");
- _builder.append(portClassName, " ");
- _builder.append("(etRuntime::IEventReceiver actor, char* name, int localId, etRuntime::Address addr, etRuntime::Address peerAddress); ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t ");
- _builder.append(portClassName, " ");
- _builder.append("(etRuntime::IEventReceiver actor, char* name, int localId, int idx, etRuntime::Address addr, etRuntime::Address peerAddress);");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t ");
- _builder.append("virtual void receive(etRuntime::Message m);");
- _builder.newLine();
- {
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(pclass, null);
- if (_operator_notEquals_1) {
- _builder.append("\t");
- EList<Attribute> _attributes = pclass.getAttributes();
- StringConcatenation _attributes_1 = this.helpers.attributes(_attributes);
- _builder.append(_attributes_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- EList<PortOperation> _operations = pclass.getOperations();
- StringConcatenation _operationsDeclaration = this.helpers.operationsDeclaration(_operations, portClassName);
- _builder.append(_operationsDeclaration, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t ");
- _builder.append("// sent messages");
- _builder.newLine();
- {
- List<Message> _outgoing = this.roomExt.getOutgoing(pc, conj);
- for(final Message m : _outgoing) {
- _builder.append("\t");
- StringConcatenation _sendMessageDeclaration = this.sendMessageDeclaration(m, conj);
- _builder.append(_sendMessageDeclaration, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("};");
- _builder.newLine();
- _builder.newLine();
- _builder.append("//------------------------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.append("// ");
- {
- if (conj) {
- _builder.append("conjugated ");
- }
- }
- _builder.append("replicated port class");
- _builder.newLineIfNotEmpty();
- _builder.append("//------------------------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.append("class ");
- _builder.append(replPortClassName, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("private:");
- _builder.newLine();
- _builder.append("\t ");
- _builder.append("std::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 _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.EVENT_DRIVEN);
- if (_operator_equals) {
- {
- if (conj) {
- _builder.append("\t");
- _builder.append("// incoming messages");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- for(final Message m_1 : _allIncomingMessages) {
- _builder.append("\t");
- StringConcatenation _messageSignature = this.messageSignature(m_1);
- _builder.append(_messageSignature, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- } else {
- _builder.append("\t");
- _builder.append("// outgoing messages");
- _builder.newLine();
- {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- for(final Message m_2 : _allOutgoingMessages) {
- _builder.append("\t");
- StringConcatenation _messageSignature_1 = this.messageSignature(m_2);
- _builder.append(_messageSignature_1, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- } else {
- CommunicationType _commType_1 = pc.getCommType();
- boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, CommunicationType.DATA_DRIVEN);
- if (_operator_equals_1) {
- _builder.append(" ");
- _builder.append("/*--------------------- port structs and methods */");
- _builder.newLine();
- StringConcatenation _genDataDrivenPortHeaders = this.genDataDrivenPortHeaders(pc);
- _builder.append(_genDataDrivenPortHeaders, "");
- _builder.newLineIfNotEmpty();
- } else {
- CommunicationType _commType_2 = pc.getCommType();
- boolean _operator_equals_2 = ObjectExtensions.operator_equals(_commType_2, CommunicationType.SYNCHRONOUS);
- if (_operator_equals_2) {
- _builder.append("#error \"synchronous protocols not implemented yet\"");
- _builder.newLine();
- }
- }
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("};");
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public StringConcatenation portClassImplementation(final ProtocolClass pc, final Boolean conj) {
- StringConcatenation _xblockexpression = null;
- {
- PortClass _portClass = this.roomExt.getPortClass(pc, conj);
- PortClass pclass = _portClass;
- String _portClassName = this.roomExt.getPortClassName(pc, conj);
- String portClassName = _portClassName;
- String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
- String replPortClassName = _portClassName_1;
- StringConcatenation _builder = new StringConcatenation();
- String _name = pc.getName();
- _builder.append(_name, "");
- _builder.append("::");
- _builder.append(portClassName, "");
- _builder.append("::");
- _builder.append(portClassName, "");
- _builder.append("(IEventReceiver actor, char* name, int localId, Address addr, Address peerAddress)");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(": PortBase(actor, name, localId, 0, addr, peerAddress)");
- _builder.newLine();
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("DebuggingService::getInstance().addPortInstance(*this);");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- String _name_1 = pc.getName();
- _builder.append(_name_1, "");
- _builder.append("::");
- _builder.append(portClassName, "");
- _builder.append("::");
- _builder.append(portClassName, "");
- _builder.append("(IEventReceiver actor, char* name, int localId, int idx, Address addr, Address peerAddress)");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(": PortBase(actor, name, localId, idx, addr, peerAddress)");
- _builder.newLine();
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("DebuggingService::getInstance().addPortInstance(*this);");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("void ");
- String _name_2 = pc.getName();
- _builder.append(_name_2, "");
- _builder.append("::");
- _builder.append(portClassName, "");
- _builder.append("::receive(Message 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);
- if (_handlesReceive) {
- _builder.append("\t");
- _builder.append("switch (msg.getEvtId()) {");
- _builder.newLine();
- {
- List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, conj);
- for(final MessageHandler hdlr : _receiveHandlers) {
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("case ");
- Message _msg = hdlr.getMsg();
- String _codeName = this.roomExt.getCodeName(_msg);
- _builder.append(_codeName, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("{");
- _builder.newLine();
- {
- DetailCode _detailCode = hdlr.getDetailCode();
- EList<String> _commands = _detailCode.getCommands();
- for(final String command : _commands) {
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append(command, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("break;");
- _builder.newLine();
- }
- }
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("default:");
- _builder.newLine();
- _builder.append("\t");
- }
- }
- _builder.append("\tgetActor().receiveEvent(*this, msg.getEvtId(), msg.getData());");
- _builder.newLineIfNotEmpty();
- {
- boolean _handlesReceive_1 = this.roomExt.handlesReceive(pc, conj);
- if (_handlesReceive_1) {
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("}");
- _builder.newLine();
- {
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(pclass, null);
- if (_operator_notEquals) {
- EList<PortOperation> _operations = pclass.getOperations();
- StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations, portClassName);
- _builder.append(_operationsImplementation, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("// sent messages");
- _builder.newLine();
- {
- List<Message> _outgoing = this.roomExt.getOutgoing(pc, conj);
- for(final Message m : _outgoing) {
- String _name_3 = pc.getName();
- String _operator_plus = StringExtensions.operator_plus(_name_3, "::");
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, portClassName);
- StringConcatenation _sendMessage = this.sendMessage(m, _operator_plus_1, conj);
- _builder.append(_sendMessage, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("//-------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.append("// replicated port class");
- _builder.newLine();
- _builder.append("//-------------------------------------------------------------------------------");
- _builder.newLine();
- String _name_4 = pc.getName();
- _builder.append(_name_4, "");
- _builder.append("::");
- _builder.append(replPortClassName, "");
- _builder.append("::");
- _builder.append(replPortClassName, "");
- _builder.append("(IEventReceiver actor, char* name, int localId, 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) {
- _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 _operator_plus_2 = StringExtensions.operator_plus(_name_7, "::");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, replPortClassName);
- StringConcatenation _messageSignatureDefinition = this.messageSignatureDefinition(m_1, _operator_plus_3);
- _builder.append(_messageSignatureDefinition, "");
- _builder.append("{");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("for (int i=0; i<replication; ++i) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("ports[i].");
- StringConcatenation _messageCall = this.messageCall(m_1);
- _builder.append(_messageCall, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- }
- }
- } else {
- _builder.append("// outgoing messages");
- _builder.newLine();
- {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- for(final Message m_2 : _allOutgoingMessages) {
- String _name_8 = pc.getName();
- String _operator_plus_4 = StringExtensions.operator_plus(_name_8, "::");
- String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, replPortClassName);
- StringConcatenation _messageSignatureDefinition_1 = this.messageSignatureDefinition(m_2, _operator_plus_5);
- _builder.append(_messageSignatureDefinition_1, "");
- _builder.append("{");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("for (int i=0; i<replication; ++i) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("ports[i].");
- StringConcatenation _messageCall_1 = this.messageCall(m_2);
- _builder.append(_messageCall_1, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private StringConcatenation generateSourceFile(final Root root, final ProtocolClass pc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("\t");
- _builder.append("/**");
- _builder.newLine();
- _builder.append("\t ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append("\t ");
- _builder.append("*");
- _builder.newLine();
- _builder.append("\t ");
- _builder.append("* Source File of ProtocolClass ");
- String _name = pc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append("\t ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"");
- String _cppHeaderFileName = this.stdExt.getCppHeaderFileName(pc);
- _builder.append(_cppHeaderFileName, " ");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("#include \"common/debugging/DebuggingService.h\"");
- _builder.newLine();
- _builder.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();
- StringConcatenation _userCode = this.helpers.userCode(_userCode3);
- _builder.append(_userCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- {
- CommunicationType _commType = pc.getCommType();
- boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.EVENT_DRIVEN);
- if (_operator_equals) {
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//----------------------------------------------");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// java code");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//----------------------------------------------");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- DetailCode _userCode2 = pc.getUserCode2();
- StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("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");
- StringConcatenation _portClassImplementation = this.portClassImplementation(pc, ((Boolean)false));
- _builder.append(_portClassImplementation, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- StringConcatenation _portClassImplementation_1 = this.portClassImplementation(pc, ((Boolean)true));
- _builder.append(_portClassImplementation_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/*--------------------- debug helpers */");
- _builder.newLine();
- _builder.append("\t");
- StringConcatenation _generateDebugHelpersImplementation = this.generateDebugHelpersImplementation(root, pc);
- _builder.append(_generateDebugHelpersImplementation, " ");
- _builder.newLineIfNotEmpty();
- } else {
- CommunicationType _commType_1 = pc.getCommType();
- boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, CommunicationType.DATA_DRIVEN);
- if (_operator_equals_1) {
- StringConcatenation _genDataDrivenPortSources = this.genDataDrivenPortSources(pc);
- _builder.append(_genDataDrivenPortSources, "");
- _builder.newLineIfNotEmpty();
- } else {
- CommunicationType _commType_2 = pc.getCommType();
- boolean _operator_equals_2 = ObjectExtensions.operator_equals(_commType_2, CommunicationType.SYNCHRONOUS);
- if (_operator_equals_2) {
- _builder.append("#error \"synchronoue protocols not implemented yet\"");
- _builder.newLine();
- }
- }
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- return _builder;
- }
-
- private StringConcatenation portClassHeader(final ProtocolClass pc, final Boolean conj) {
- StringConcatenation _xblockexpression = null;
- {
- String _portClassName = this.roomExt.getPortClassName(pc, conj);
- String portClassName = _portClassName;
- String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
- String replPortClassName = _portClassName_1;
- List<Message> _xifexpression = null;
- if (conj) {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- _xifexpression = _allIncomingMessages;
- } else {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- _xifexpression = _allOutgoingMessages;
- }
- List<Message> messages = _xifexpression;
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("typedef etPort ");
- _builder.append(portClassName, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("typedef etReplPort ");
- _builder.append(replPortClassName, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- PortClass _portClass = this.roomExt.getPortClass(pc, conj);
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_portClass, null);
- if (_operator_notEquals) {
- {
- PortClass _portClass_1 = this.roomExt.getPortClass(pc, conj);
- EList<Attribute> _attributes = _portClass_1.getAttributes();
- boolean _isEmpty = _attributes.isEmpty();
- boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
- if (_operator_not) {
- _builder.append("/* variable part of PortClass (RAM) */");
- _builder.newLine();
- _builder.append("typedef struct ");
- _builder.append(portClassName, "");
- _builder.append("_var ");
- _builder.append(portClassName, "");
- _builder.append("_var; ");
- _builder.newLineIfNotEmpty();
- _builder.append("struct ");
- _builder.append(portClassName, "");
- _builder.append("_var {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- PortClass _portClass_2 = this.roomExt.getPortClass(pc, conj);
- EList<Attribute> _attributes_1 = _portClass_2.getAttributes();
- StringConcatenation _attributes_2 = this.helpers.attributes(_attributes_1);
- _builder.append(_attributes_2, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("};");
- _builder.newLine();
- {
- PortClass _portClass_3 = this.roomExt.getPortClass(pc, conj);
- EList<Attribute> _attributes_3 = _portClass_3.getAttributes();
- for(final Attribute a : _attributes_3) {
- {
- String _defaultValueLiteral = a.getDefaultValueLiteral();
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_defaultValueLiteral, null);
- if (_operator_notEquals_1) {
- _builder.append("\t\t\t\t");
- String _operator_plus = StringExtensions.operator_plus(portClassName, " ");
- String _name = a.getName();
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _name);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ": Attribute initialization not supported in C");
- this.logger.logInfo(_operator_plus_2);
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- }
- }
- }
- }
- _builder.append("\t");
- _builder.newLine();
- {
- for(final Message message : messages) {
- VarDecl _data = message.getData();
- boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_data, null);
- boolean hasData = _operator_notEquals_2;
- _builder.newLineIfNotEmpty();
- String _xifexpression_1 = null;
- if (hasData) {
- VarDecl _data_1 = message.getData();
- RefableType _refType = _data_1.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this._typeHelpers.typeName(_type);
- _xifexpression_1 = _typeName;
- } else {
- _xifexpression_1 = "";
- }
- String typeName = _xifexpression_1;
- _builder.newLineIfNotEmpty();
- String _xifexpression_2 = null;
- boolean _operator_and = false;
- if (!hasData) {
- _operator_and = false;
- } else {
- boolean _operator_or = false;
- VarDecl _data_2 = message.getData();
- RefableType _refType_1 = _data_2.getRefType();
- DataType _type_1 = _refType_1.getType();
- boolean _operator_not_1 = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType));
- if (_operator_not_1) {
- _operator_or = true;
- } else {
- VarDecl _data_3 = message.getData();
- RefableType _refType_2 = _data_3.getRefType();
- boolean _isRef = _refType_2.isRef();
- _operator_or = BooleanExtensions.operator_or(_operator_not_1, _isRef);
- }
- _operator_and = BooleanExtensions.operator_and(hasData, _operator_or);
- }
- if (_operator_and) {
- _xifexpression_2 = "*";
- } else {
- _xifexpression_2 = "";
- }
- String refp = _xifexpression_2;
- _builder.newLineIfNotEmpty();
- String _xifexpression_3 = null;
- if (hasData) {
- String _operator_plus_3 = StringExtensions.operator_plus(", ", typeName);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, refp);
- String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, " data");
- _xifexpression_3 = _operator_plus_5;
- } else {
- _xifexpression_3 = "";
- }
- String data = _xifexpression_3;
- _builder.newLineIfNotEmpty();
- String _name_1 = message.getName();
- String _messageSignature = this.messageSignature(portClassName, _name_1, "", data);
- _builder.append(_messageSignature, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- String _name_2 = message.getName();
- String _messageSignature_1 = this.messageSignature(replPortClassName, _name_2, "_broadcast", data);
- _builder.append(_messageSignature_1, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- String _name_3 = message.getName();
- String _operator_plus_6 = StringExtensions.operator_plus(", int idx", data);
- String _messageSignature_2 = this.messageSignature(replPortClassName, _name_3, "", _operator_plus_6);
- _builder.append(_messageSignature_2, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- {
- PortClass _portClass_4 = this.roomExt.getPortClass(pc, conj);
- boolean _operator_notEquals_3 = ObjectExtensions.operator_notEquals(_portClass_4, null);
- if (_operator_notEquals_3) {
- PortClass _portClass_5 = this.roomExt.getPortClass(pc, conj);
- EList<PortOperation> _operations = _portClass_5.getOperations();
- StringConcatenation _operationsDeclaration = this.helpers.operationsDeclaration(_operations, portClassName);
- _builder.append(_operationsDeclaration, "");
- _builder.newLineIfNotEmpty();
- PortClass _portClass_6 = this.roomExt.getPortClass(pc, conj);
- EList<PortOperation> _operations_1 = _portClass_6.getOperations();
- StringConcatenation _operationsDeclaration_1 = this.helpers.operationsDeclaration(_operations_1, replPortClassName);
- _builder.append(_operationsDeclaration_1, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- {
- boolean _handlesReceive = this.roomExt.handlesReceive(pc, conj);
- if (_handlesReceive) {
- {
- List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, conj);
- for(final MessageHandler h : _receiveHandlers) {
- _builder.append("void ");
- _builder.append(portClassName, "");
- _builder.append("_");
- Message _msg = h.getMsg();
- String _name_4 = _msg.getName();
- _builder.append(_name_4, "");
- _builder.append("_receiveHandler(");
- _builder.append(portClassName, "");
- _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc);");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private StringConcatenation genDataDrivenPortHeaders(final ProtocolClass pc) {
- StringConcatenation _xblockexpression = null;
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
- public Boolean apply(final Message m) {
- VarDecl _data = m.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- return ((Boolean)_operator_notEquals);
- }
- };
- Iterable<Message> _filter = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
- Iterable<Message> sentMsgs = _filter;
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/* data driven send port (conjugated) */");
- _builder.newLine();
- _builder.append("typedef struct {");
- _builder.newLine();
- {
- for(final Message msg : sentMsgs) {
- _builder.append("\t");
- VarDecl _data = msg.getData();
- RefableType _refType = _data.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this._typeHelpers.typeName(_type);
- String typeName = _typeName;
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _xifexpression = null;
- VarDecl _data_1 = msg.getData();
- RefableType _refType_1 = _data_1.getRefType();
- boolean _isRef = _refType_1.isRef();
- if (_isRef) {
- _xifexpression = "*";
- } else {
- _xifexpression = "";
- }
- String refp = _xifexpression;
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(typeName, " ");
- _builder.append(refp, " ");
- _builder.append(" ");
- String _name = msg.getName();
- _builder.append(_name, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("}");
- _builder.newLine();
- String _portClassName = this.roomExt.getPortClassName(pc, true);
- _builder.append(_portClassName, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* data driven receive port (regular) */");
- _builder.newLine();
- _builder.append("typedef struct {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("const ");
- String _portClassName_1 = this.roomExt.getPortClassName(pc, true);
- _builder.append(_portClassName_1, " ");
- _builder.append("* peer;");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- String _portClassName_2 = this.roomExt.getPortClassName(pc, false);
- _builder.append(_portClassName_2, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- for(final Message message : sentMsgs) {
- VarDecl _data_2 = message.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data_2, null);
- boolean hasData = _operator_notEquals;
- _builder.newLineIfNotEmpty();
- String _xifexpression_1 = null;
- if (hasData) {
- VarDecl _data_3 = message.getData();
- RefableType _refType_2 = _data_3.getRefType();
- DataType _type_1 = _refType_2.getType();
- String _typeName_1 = this._typeHelpers.typeName(_type_1);
- _xifexpression_1 = _typeName_1;
- } else {
- _xifexpression_1 = "";
- }
- String typeName_1 = _xifexpression_1;
- _builder.newLineIfNotEmpty();
- String _xifexpression_2 = null;
- boolean _operator_and = false;
- if (!hasData) {
- _operator_and = false;
- } else {
- VarDecl _data_4 = message.getData();
- RefableType _refType_3 = _data_4.getRefType();
- DataType _type_2 = _refType_3.getType();
- boolean _operator_not = BooleanExtensions.operator_not((_type_2 instanceof PrimitiveType));
- _operator_and = BooleanExtensions.operator_and(hasData, _operator_not);
- }
- if (_operator_and) {
- _xifexpression_2 = "*";
- } else {
- _xifexpression_2 = "";
- }
- String refp_1 = _xifexpression_2;
- _builder.newLineIfNotEmpty();
- String _xifexpression_3 = null;
- if (hasData) {
- String _operator_plus = StringExtensions.operator_plus(", ", typeName_1);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refp_1);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
- _xifexpression_3 = _operator_plus_2;
- } else {
- _xifexpression_3 = "";
- }
- String data = _xifexpression_3;
- _builder.newLineIfNotEmpty();
- String _portClassName_3 = this.roomExt.getPortClassName(pc, true);
- String _name_1 = message.getName();
- String _messageSetterSignature = this.messageSetterSignature(_portClassName_3, _name_1, data);
- _builder.append(_messageSetterSignature, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- String _portClassName_4 = this.roomExt.getPortClassName(pc, false);
- String _name_2 = message.getName();
- String _messageGetterSignature = this.messageGetterSignature(_portClassName_4, _name_2, typeName_1);
- _builder.append(_messageGetterSignature, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private StringConcatenation genDataDrivenPortSources(final ProtocolClass pc) {
- StringConcatenation _xblockexpression = null;
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
- public Boolean apply(final Message m) {
- VarDecl _data = m.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- return ((Boolean)_operator_notEquals);
- }
- };
- Iterable<Message> _filter = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
- Iterable<Message> messages = _filter;
- StringConcatenation _builder = new StringConcatenation();
- {
- for(final Message message : messages) {
- VarDecl _data = message.getData();
- RefableType _refType = _data.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this._typeHelpers.typeName(_type);
- String typeName = _typeName;
- _builder.newLineIfNotEmpty();
- String _xifexpression = null;
- VarDecl _data_1 = message.getData();
- RefableType _refType_1 = _data_1.getRefType();
- DataType _type_1 = _refType_1.getType();
- boolean _operator_not = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType));
- if (_operator_not) {
- _xifexpression = "*";
- } else {
- _xifexpression = "";
- }
- String refp = _xifexpression;
- _builder.newLineIfNotEmpty();
- String _xifexpression_1 = null;
- VarDecl _data_2 = message.getData();
- RefableType _refType_2 = _data_2.getRefType();
- DataType _type_2 = _refType_2.getType();
- if ((_type_2 instanceof PrimitiveType)) {
- _xifexpression_1 = "&";
- } else {
- _xifexpression_1 = "";
- }
- String refa = _xifexpression_1;
- _builder.newLineIfNotEmpty();
- String _operator_plus = StringExtensions.operator_plus(", ", typeName);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refp);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
- String data = _operator_plus_2;
- _builder.newLineIfNotEmpty();
- String _portClassName = this.roomExt.getPortClassName(pc, true);
- String _name = message.getName();
- String _messageSetterSignature = this.messageSetterSignature(_portClassName, _name, data);
- _builder.append(_messageSetterSignature, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("self->");
- String _name_1 = message.getName();
- _builder.append(_name_1, " ");
- _builder.append(" = data;");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- String _portClassName_1 = this.roomExt.getPortClassName(pc, false);
- String _name_2 = message.getName();
- String _messageGetterSignature = this.messageGetterSignature(_portClassName_1, _name_2, typeName);
- _builder.append(_messageGetterSignature, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("return self->peer->");
- String _name_3 = message.getName();
- _builder.append(_name_3, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private StringConcatenation portClassSource(final ProtocolClass pc, final Boolean conj) {
- StringConcatenation _xblockexpression = null;
- {
- String _portClassName = this.roomExt.getPortClassName(pc, conj);
- String portClassName = _portClassName;
- String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
- String replPortClassName = _portClassName_1;
- List<Message> _xifexpression = null;
- if (conj) {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- _xifexpression = _allIncomingMessages;
- } else {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- _xifexpression = _allOutgoingMessages;
- }
- List<Message> messages = _xifexpression;
- String _xifexpression_1 = null;
- if (conj) {
- _xifexpression_1 = "IN_";
- } else {
- _xifexpression_1 = "OUT_";
- }
- String dir = _xifexpression_1;
- StringConcatenation _builder = new StringConcatenation();
- {
- for(final Message message : messages) {
- VarDecl _data = message.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- boolean hasData = _operator_notEquals;
- _builder.newLineIfNotEmpty();
- String _xifexpression_2 = null;
- if (hasData) {
- VarDecl _data_1 = message.getData();
- RefableType _refType = _data_1.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this._typeHelpers.typeName(_type);
- _xifexpression_2 = _typeName;
- } else {
- _xifexpression_2 = "";
- }
- String typeName = _xifexpression_2;
- _builder.newLineIfNotEmpty();
- String _xifexpression_3 = null;
- boolean _operator_and = false;
- if (!hasData) {
- _operator_and = false;
- } else {
- VarDecl _data_2 = message.getData();
- RefableType _refType_1 = _data_2.getRefType();
- boolean _isRef = _refType_1.isRef();
- _operator_and = BooleanExtensions.operator_and(hasData, _isRef);
- }
- if (_operator_and) {
- _xifexpression_3 = "*";
- } else {
- _xifexpression_3 = "";
- }
- String refp = _xifexpression_3;
- _builder.newLineIfNotEmpty();
- String _xifexpression_4 = null;
- boolean _operator_and_1 = false;
- if (!hasData) {
- _operator_and_1 = false;
- } else {
- boolean _operator_or = false;
- VarDecl _data_3 = message.getData();
- RefableType _refType_2 = _data_3.getRefType();
- DataType _type_1 = _refType_2.getType();
- boolean _operator_not = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType));
- if (_operator_not) {
- _operator_or = true;
- } else {
- VarDecl _data_4 = message.getData();
- RefableType _refType_3 = _data_4.getRefType();
- boolean _isRef_1 = _refType_3.isRef();
- _operator_or = BooleanExtensions.operator_or(_operator_not, _isRef_1);
- }
- _operator_and_1 = BooleanExtensions.operator_and(hasData, _operator_or);
- }
- if (_operator_and_1) {
- _xifexpression_4 = "*";
- } else {
- _xifexpression_4 = "";
- }
- String refpd = _xifexpression_4;
- _builder.newLineIfNotEmpty();
- String _xifexpression_5 = null;
- boolean _operator_and_2 = false;
- boolean _operator_and_3 = false;
- if (!hasData) {
- _operator_and_3 = false;
- } else {
- VarDecl _data_5 = message.getData();
- RefableType _refType_4 = _data_5.getRefType();
- DataType _type_2 = _refType_4.getType();
- boolean _operator_not_1 = BooleanExtensions.operator_not((_type_2 instanceof PrimitiveType));
- _operator_and_3 = BooleanExtensions.operator_and(hasData, _operator_not_1);
- }
- if (!_operator_and_3) {
- _operator_and_2 = false;
- } else {
- VarDecl _data_6 = message.getData();
- RefableType _refType_5 = _data_6.getRefType();
- boolean _isRef_2 = _refType_5.isRef();
- boolean _operator_not_2 = BooleanExtensions.operator_not(_isRef_2);
- _operator_and_2 = BooleanExtensions.operator_and(_operator_and_3, _operator_not_2);
- }
- if (_operator_and_2) {
- _xifexpression_5 = "";
- } else {
- _xifexpression_5 = "&";
- }
- String refa = _xifexpression_5;
- _builder.newLineIfNotEmpty();
- String _xifexpression_6 = null;
- if (hasData) {
- String _operator_plus = StringExtensions.operator_plus(", ", typeName);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refpd);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
- _xifexpression_6 = _operator_plus_2;
- } else {
- _xifexpression_6 = "";
- }
- String data = _xifexpression_6;
- _builder.newLineIfNotEmpty();
- String _xifexpression_7 = null;
- if (hasData) {
- _xifexpression_7 = ", data";
- } else {
- _xifexpression_7 = "";
- }
- String dataCall = _xifexpression_7;
- _builder.newLineIfNotEmpty();
- MessageHandler _sendHandler = this.roomExt.getSendHandler(message, conj);
- MessageHandler hdlr = _sendHandler;
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- String _name = message.getName();
- String _messageSignature = this.messageSignature(portClassName, _name, "", data);
- _builder.append(_messageSignature, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- {
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(hdlr, null);
- if (_operator_notEquals_1) {
- _builder.append("\t");
- {
- DetailCode _detailCode = hdlr.getDetailCode();
- EList<String> _commands = _detailCode.getCommands();
- for(final String command : _commands) {
- _builder.append("\t");
- _builder.append(command, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- } else {
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- _builder.append(portClassName, " ");
- _builder.append("\", \"");
- String _name_1 = message.getName();
- _builder.append(_name_1, " ");
- _builder.append("\")");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- String _name_2 = pc.getName();
- String _name_3 = message.getName();
- String _operator_plus_3 = StringExtensions.operator_plus(dir, _name_3);
- String _memberInUse = this.stdExt.memberInUse(_name_2, _operator_plus_3);
- String _operator_plus_4 = StringExtensions.operator_plus(typeName, refp);
- String _operator_plus_5 = StringExtensions.operator_plus(refa, "data");
- String _sendMessageCall = this.sendMessageCall(hasData, "self", _memberInUse, _operator_plus_4, _operator_plus_5);
- _builder.append(_sendMessageCall, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
- _builder.newLine();
- }
- }
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- String _name_4 = message.getName();
- String _messageSignature_1 = this.messageSignature(replPortClassName, _name_4, "_broadcast", data);
- _builder.append(_messageSignature_1, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- {
- boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(hdlr, null);
- if (_operator_notEquals_2) {
- _builder.append("\t");
- _builder.append("int i;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("for (i=0; i<((etReplPort*)self)->size; ++i) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append(portClassName, " ");
- _builder.append("_");
- String _name_5 = message.getName();
- _builder.append(_name_5, " ");
- _builder.append("((etPort*)&((etReplPort*)self)->ports[i]");
- _builder.append(dataCall, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}\t\t\t\t\t");
- _builder.newLine();
- } else {
- _builder.append("\t");
- _builder.append("int i;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- _builder.append(replPortClassName, " ");
- _builder.append("\", \"");
- String _name_6 = message.getName();
- _builder.append(_name_6, " ");
- _builder.append("\")");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("for (i=0; i<((etReplPort*)self)->size; ++i) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- String _name_7 = pc.getName();
- String _name_8 = message.getName();
- String _operator_plus_6 = StringExtensions.operator_plus(dir, _name_8);
- String _memberInUse_1 = this.stdExt.memberInUse(_name_7, _operator_plus_6);
- String _operator_plus_7 = StringExtensions.operator_plus(typeName, refp);
- String _operator_plus_8 = StringExtensions.operator_plus(refa, "data");
- String _sendMessageCall_1 = this.sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[i])", _memberInUse_1, _operator_plus_7, _operator_plus_8);
- _builder.append(_sendMessageCall_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
- _builder.newLine();
- }
- }
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- String _name_9 = message.getName();
- String _operator_plus_9 = StringExtensions.operator_plus(", int idx", data);
- String _messageSignature_2 = this.messageSignature(replPortClassName, _name_9, "", _operator_plus_9);
- _builder.append(_messageSignature_2, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- {
- boolean _operator_notEquals_3 = ObjectExtensions.operator_notEquals(hdlr, null);
- if (_operator_notEquals_3) {
- _builder.append("\t");
- _builder.append(portClassName, " ");
- _builder.append("_");
- String _name_10 = message.getName();
- _builder.append(_name_10, " ");
- _builder.append("((etPort*)&((etReplPort*)self)->ports[idx]");
- _builder.append(dataCall, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- _builder.append(replPortClassName, " ");
- _builder.append("\", \"");
- String _name_11 = message.getName();
- _builder.append(_name_11, " ");
- _builder.append("\")");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if (0<=idx && idx<((etReplPort*)self)->size) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- String _name_12 = pc.getName();
- String _name_13 = message.getName();
- String _operator_plus_10 = StringExtensions.operator_plus(dir, _name_13);
- String _memberInUse_2 = this.stdExt.memberInUse(_name_12, _operator_plus_10);
- String _operator_plus_11 = StringExtensions.operator_plus(typeName, refp);
- String _operator_plus_12 = StringExtensions.operator_plus(refa, "data");
- String _sendMessageCall_2 = this.sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[idx])", _memberInUse_2, _operator_plus_11, _operator_plus_12);
- _builder.append(_sendMessageCall_2, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
- _builder.newLine();
- }
- }
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.newLine();
- {
- PortClass _portClass = this.roomExt.getPortClass(pc, conj);
- boolean _operator_notEquals_4 = ObjectExtensions.operator_notEquals(_portClass, null);
- if (_operator_notEquals_4) {
- PortClass _portClass_1 = this.roomExt.getPortClass(pc, conj);
- EList<PortOperation> _operations = _portClass_1.getOperations();
- StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations, portClassName);
- _builder.append(_operationsImplementation, "");
- _builder.newLineIfNotEmpty();
- PortClass _portClass_2 = this.roomExt.getPortClass(pc, conj);
- EList<PortOperation> _operations_1 = _portClass_2.getOperations();
- StringConcatenation _operationsImplementation_1 = this.helpers.operationsImplementation(_operations_1, replPortClassName);
- _builder.append(_operationsImplementation_1, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("// getReplication");
- _builder.newLine();
- _builder.append("etInt32 ");
- _builder.append(replPortClassName, "");
- _builder.append("_getReplication(const ");
- _builder.append(replPortClassName, "");
- _builder.append("* self) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("return ((etReplPort*)self)->size;");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- {
- boolean _handlesReceive = this.roomExt.handlesReceive(pc, conj);
- if (_handlesReceive) {
- StringConcatenation _genReceiveHandlers = this.genReceiveHandlers(pc, conj);
- _builder.append(_genReceiveHandlers, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private String sendMessageCall(final boolean hasData, final String self, final String msg, final String typeName, final String data) {
- String _xifexpression = null;
- if (hasData) {
- String _operator_plus = StringExtensions.operator_plus("etPort_sendMessage(", self);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, ", ");
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, msg);
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, ", sizeof(");
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, typeName);
- String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "), ");
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, data);
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ");");
- _xifexpression = _operator_plus_7;
- } else {
- String _operator_plus_8 = StringExtensions.operator_plus("etPort_sendMessage(", self);
- String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_8, ", ");
- String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, msg);
- String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, ", 0, NULL);");
- _xifexpression = _operator_plus_11;
- }
- return _xifexpression;
- }
-
- private String messageSignature(final String className, final String messageName, final String methodSuffix, final String data) {
- String _operator_plus = StringExtensions.operator_plus("void ", className);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, "_");
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, messageName);
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, methodSuffix);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "(const ");
- String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, className);
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "* self");
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, data);
- String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, ")");
- return _operator_plus_8;
- }
-
- private String messageSetterSignature(final String className, final String messageName, final String data) {
- String _operator_plus = StringExtensions.operator_plus("void ", className);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, "_");
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, messageName);
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, "_set(");
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, className);
- String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "* self");
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, data);
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ")");
- return _operator_plus_7;
- }
-
- private String messageGetterSignature(final String className, final String messageName, final String type) {
- String _operator_plus = StringExtensions.operator_plus(type, " ");
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, className);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "_");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, messageName);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "_get(const ");
- String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, className);
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "* const self)");
- return _operator_plus_6;
- }
-
- private StringConcatenation messageCall(final Message m) {
- StringConcatenation _builder = new StringConcatenation();
- String _name = m.getName();
- _builder.append(_name, "");
- _builder.append("(");
- {
- VarDecl _data = m.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- if (_operator_notEquals) {
- _builder.append(" ");
- VarDecl _data_1 = m.getData();
- String _name_1 = _data_1.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- private StringConcatenation genReceiveHandlers(final ProtocolClass pc, final Boolean conj) {
- StringConcatenation _xblockexpression = null;
- {
- String _portClassName = this.roomExt.getPortClassName(pc, conj);
- String portClassName = _portClassName;
- String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
- String replPortClassName = _portClassName_1;
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/* receiver handlers */");
- _builder.newLine();
- {
- List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, conj);
- for(final MessageHandler h : _receiveHandlers) {
- _builder.append("void ");
- _builder.append(portClassName, "");
- _builder.append("_");
- Message _msg = h.getMsg();
- String _name = _msg.getName();
- _builder.append(_name, "");
- _builder.append("_receiveHandler(");
- _builder.append(portClassName, "");
- _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- DetailCode _detailCode = h.getDetailCode();
- StringConcatenation _userCode = this.helpers.userCode(_detailCode);
- _builder.append(_userCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("/* hand over the message to the actor: */");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/* (*receiveMessageFunc)(actor, self, msg); */");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private StringConcatenation generateDebugHelpersImplementation(final Root root, final ProtocolClass pc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.newLine();
- _builder.append("/* message names as strings for debugging (generate MSC) */");
- _builder.newLine();
- _builder.append("static const char* ");
- String _name = pc.getName();
- _builder.append(_name, "");
- _builder.append("_messageStrings[] = {\"MIN\", ");
- {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- for(final Message m : _allOutgoingMessages) {
- _builder.append("\"");
- String _name_1 = m.getName();
- _builder.append(_name_1, "");
- _builder.append("\",");
- }
- }
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- for(final Message m_1 : _allIncomingMessages) {
- _builder.append("\"");
- String _name_2 = m_1.getName();
- _builder.append(_name_2, "");
- _builder.append("\", ");
- }
- }
- _builder.append("\"MAX\"};");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("const char* ");
- String _name_3 = pc.getName();
- _builder.append(_name_3, "");
- _builder.append("_getMessageString(int msg_id) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if (msg_id < ");
- String _name_4 = pc.getName();
- _builder.append(_name_4, " ");
- _builder.append("::MSG_MIN || msg_id > ");
- String _name_5 = pc.getName();
- _builder.append(_name_5, " ");
- _builder.append("::MSG_MAX+1){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("/* id out of range */");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("return \"Message ID out of range\";");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("else{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("return ");
- String _name_6 = pc.getName();
- _builder.append(_name_6, " ");
- _builder.append("_messageStrings[msg_id];");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- return _builder;
- }
-
- public StringConcatenation messageSignature(final Message m) {
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean _isPriv = m.isPriv();
- if (_isPriv) {
- _builder.append("private:");
- } else {
- _builder.append("public:");
- }
- }
- _builder.append(" void ");
- String _name = m.getName();
- _builder.append(_name, "");
- _builder.append("(");
- {
- VarDecl _data = m.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- if (_operator_notEquals) {
- VarDecl _data_1 = m.getData();
- RefableType _refType = _data_1.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this._typeHelpers.typeName(_type);
- _builder.append(_typeName, "");
- _builder.append(" ");
- VarDecl _data_2 = m.getData();
- String _name_1 = _data_2.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- return _builder;
- }
-
- public StringConcatenation messageSignatureExplicit(final Message m) {
- StringConcatenation _xblockexpression = null;
- {
- VarDecl _data = m.getData();
- RefableType _refType = _data.getRefType();
- DataType _type = _refType.getType();
- DataClass dc = ((DataClass) _type);
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("public: void ");
- String _name = m.getName();
- _builder.append(_name, "");
- _builder.append("(");
- {
- DataClass _base = dc.getBase();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
- if (_operator_notEquals) {
- DataClass _base_1 = dc.getBase();
- String _typeName = this._typeHelpers.typeName(_base_1);
- _builder.append(_typeName, "");
- _builder.append(" _super, ");
- }
- }
- {
- EList<Attribute> _attributes = dc.getAttributes();
- boolean hasAnyElements = false;
- for(final Attribute a : _attributes) {
- if (!hasAnyElements) {
- hasAnyElements = true;
- } else {
- _builder.appendImmediate(", ", "");
- }
- RefableType _refType_1 = a.getRefType();
- DataType _type_1 = _refType_1.getType();
- String _typeName_1 = this._typeHelpers.typeName(_type_1);
- _builder.append(_typeName_1, "");
- {
- int _size = a.getSize();
- boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)1));
- if (_operator_greaterThan) {
- _builder.append("[]");
- }
- }
- _builder.append(" ");
- String _name_1 = a.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public StringConcatenation messageSignatureDefinition(final Message m, final String classPrefix) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("void ");
- _builder.append(classPrefix, "");
- _builder.append("::");
- String _name = m.getName();
- _builder.append(_name, "");
- _builder.append("(");
- {
- VarDecl _data = m.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- if (_operator_notEquals) {
- VarDecl _data_1 = m.getData();
- RefableType _refType = _data_1.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this._typeHelpers.typeName(_type);
- _builder.append(_typeName, "");
- _builder.append(" ");
- VarDecl _data_2 = m.getData();
- String _name_1 = _data_2.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- return _builder;
- }
-
- public StringConcatenation messageSignatureExplicitDefinition(final Message m, final String classPrefix) {
- StringConcatenation _xblockexpression = null;
- {
- VarDecl _data = m.getData();
- RefableType _refType = _data.getRefType();
- DataType _type = _refType.getType();
- DataClass dc = ((DataClass) _type);
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("void ");
- _builder.append(classPrefix, "");
- _builder.append("::");
- String _name = m.getName();
- _builder.append(_name, "");
- _builder.append("(");
- {
- DataClass _base = dc.getBase();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
- if (_operator_notEquals) {
- DataClass _base_1 = dc.getBase();
- String _typeName = this._typeHelpers.typeName(_base_1);
- _builder.append(_typeName, "");
- _builder.append(" _super, ");
- }
- }
- {
- EList<Attribute> _attributes = dc.getAttributes();
- boolean hasAnyElements = false;
- for(final Attribute a : _attributes) {
- if (!hasAnyElements) {
- hasAnyElements = true;
- } else {
- _builder.appendImmediate(", ", "");
- }
- RefableType _refType_1 = a.getRefType();
- DataType _type_1 = _refType_1.getType();
- String _typeName_1 = this._typeHelpers.typeName(_type_1);
- _builder.append(_typeName_1, "");
- {
- int _size = a.getSize();
- boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)1));
- if (_operator_greaterThan) {
- _builder.append("[]");
- }
- }
- _builder.append(" ");
- String _name_1 = a.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public StringConcatenation sendMessageDeclaration(final Message m, final boolean conj) {
- StringConcatenation _builder = new StringConcatenation();
- StringConcatenation _messageSignature = this.messageSignature(m);
- _builder.append(_messageSignature, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- {
- boolean _operator_and = false;
- VarDecl _data = m.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- if (!_operator_notEquals) {
- _operator_and = false;
- } else {
- VarDecl _data_1 = m.getData();
- RefableType _refType = _data_1.getRefType();
- DataType _type = _refType.getType();
- _operator_and = BooleanExtensions.operator_and(_operator_notEquals, (_type instanceof DataClass));
- }
- if (_operator_and) {
- StringConcatenation _messageSignatureExplicit = this.messageSignatureExplicit(m);
- _builder.append(_messageSignatureExplicit, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- return _builder;
- }
-
- public StringConcatenation sendMessage(final Message m, final String classPrefix, final boolean conj) {
- StringConcatenation _xblockexpression = null;
- {
- String _xifexpression = null;
- if (conj) {
- _xifexpression = "IN";
- } else {
- _xifexpression = "OUT";
- }
- String dir = _xifexpression;
- MessageHandler _sendHandler = this.roomExt.getSendHandler(m, conj);
- MessageHandler hdlr = _sendHandler;
- StringConcatenation _builder = new StringConcatenation();
- StringConcatenation _messageSignatureDefinition = this.messageSignatureDefinition(m, classPrefix);
- _builder.append(_messageSignatureDefinition, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- {
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(hdlr, null);
- if (_operator_notEquals) {
- _builder.append("\t");
- {
- DetailCode _detailCode = hdlr.getDetailCode();
- EList<String> _commands = _detailCode.getCommands();
- for(final String command : _commands) {
- _builder.append("\t");
- _builder.append(command, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- } else {
- _builder.append("\t");
- _builder.append("if (messageStrings[ ");
- _builder.append(dir, " ");
- _builder.append("_");
- String _name = m.getName();
- _builder.append(_name, " ");
- _builder.append("] != \"timerTick\"){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\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 _operator_equals = ObjectExtensions.operator_equals(_data, null);
- if (_operator_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 _operator_and = false;
- VarDecl _data_1 = m.getData();
- RefableType _refType = _data_1.getRefType();
- boolean _isRef = _refType.isRef();
- if (!_isRef) {
- _operator_and = false;
- } else {
- VarDecl _data_2 = m.getData();
- RefableType _refType_1 = _data_2.getRefType();
- DataType _type = _refType_1.getType();
- boolean _operator_not = BooleanExtensions.operator_not((_type instanceof PrimitiveType));
- _operator_and = BooleanExtensions.operator_and(_isRef, _operator_not);
- }
- if (_operator_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 _operator_and_1 = false;
- VarDecl _data_4 = m.getData();
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_data_4, null);
- if (!_operator_notEquals_1) {
- _operator_and_1 = false;
- } else {
- VarDecl _data_5 = m.getData();
- RefableType _refType_2 = _data_5.getRefType();
- DataType _type_1 = _refType_2.getType();
- _operator_and_1 = BooleanExtensions.operator_and(_operator_notEquals_1, (_type_1 instanceof DataClass));
- }
- if (_operator_and_1) {
- StringConcatenation _messageSignatureExplicitDefinition = this.messageSignatureExplicitDefinition(m, classPrefix);
- _builder.append(_messageSignatureExplicitDefinition, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name_5 = m.getName();
- _builder.append(_name_5, " ");
- _builder.append("(new ");
- VarDecl _data_6 = m.getData();
- RefableType _refType_3 = _data_6.getRefType();
- DataType _type_2 = _refType_3.getType();
- String _name_6 = _type_2.getName();
- _builder.append(_name_6, " ");
- _builder.append("(");
- {
- VarDecl _data_7 = m.getData();
- RefableType _refType_4 = _data_7.getRefType();
- DataType _type_3 = _refType_4.getType();
- DataClass _base = ((DataClass) _type_3).getBase();
- boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_base, null);
- if (_operator_notEquals_2) {
- _builder.append("_super, ");
- }
- }
- {
- VarDecl _data_8 = m.getData();
- RefableType _refType_5 = _data_8.getRefType();
- DataType _type_4 = _refType_5.getType();
- EList<Attribute> _attributes = ((DataClass) _type_4).getAttributes();
- boolean hasAnyElements = false;
- for(final Attribute a : _attributes) {
- if (!hasAnyElements) {
- hasAnyElements = true;
- } else {
- _builder.appendImmediate(", ", " ");
- }
- String _name_7 = a.getName();
- _builder.append(_name_7, " ");
- }
- }
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-}