Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schuetz2011-12-26 12:53:01 +0000
committerThomas Schuetz2011-12-26 12:53:01 +0000
commitb5563f0b66d9cbb2c6dc3f9d91b9b6eeef4b1ead (patch)
tree4b9e92e9938defe18cd7e351d86b9ed01cdd1fcb
parent7c8cbc7f125c97503921e8d4f1497898ab9b93aa (diff)
downloadorg.eclipse.etrice-b5563f0b66d9cbb2c6dc3f9d91b9b6eeef4b1ead.tar.gz
org.eclipse.etrice-b5563f0b66d9cbb2c6dc3f9d91b9b6eeef4b1ead.tar.xz
org.eclipse.etrice-b5563f0b66d9cbb2c6dc3f9d91b9b6eeef4b1ead.zip
[generator.c] first working and tested version of generator for DataClass
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend17
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend68
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/MainGen.xtend8
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java77
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java35
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java251
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java4
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java4
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/DataClassGen.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend11
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java77
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java62
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java24
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java4
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/ETriceGenPackage.java9
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/Root.java4
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/impl/RootImpl.java9
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/util/ETriceGenSwitch.java1
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java39
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend53
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java290
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/ATimingService.java4
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimeout.java14
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimer.java14
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPingActor.java3
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPingActor.java3
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPing.java4
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPong.java4
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/PingPongData.java27
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/PingPongDataDeep.java25
34 files changed, 687 insertions, 470 deletions
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
index 4ae2535af..c5e7c9e6c 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
@@ -95,7 +95,7 @@ class ActorClassGen {
«ENDFOR»
«helpers.Attributes(ac.attributes)»
- «helpers.Operations(ac.operations)»
+ «helpers.OperationsDeclaration(ac.operations, ac.name)»
//--------------------- construction
public «ac.name»(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
index af43028a6..459e848c7 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
@@ -86,6 +86,23 @@ class CExtensions implements ILanguageExtension {
return languageGen.getTypedData(m)
}
+ // in C no access levels can be defined
+ override String accessLevelPrivate(){""}
+ override String accessLevelProtected(){""}
+ override String accessLevelPublic(){""}
+
+ override String memberAccess(){"self->"}
+ override String selfPointer(String classname, int argumentCount){
+ if (argumentCount>0){
+ classname+"* self, "
+ }
+ else {
+ classname+"* self"
+ }
+ }
+
+ override String operationScope(String classname, boolean isDeclaration){classname+"_"}
+
//**** C-Specific
// used
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend
index c8e57cb72..d9d0938a9 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend
@@ -52,57 +52,55 @@ class DataClassGen {
}
def generateHeaderFile(Root root, DataClass dc) {'''
- TODO: includes for C-Headers instead of Java imports
+ #ifndef _«dc.name»_H_
+ #define _«dc.name»_H_
- «var models = root.getReferencedModels(dc)»
- «FOR model : models»//import «model.name».*;
+ #include "../../src/datatypes.h"
+
+ /* TODO: includes only for used DataClasses, also for other models */
+ «FOR dataClass : root.getReferencedDataClasses(dc)»«IF dataClass.name != dc.name»#include "«dataClass.name».h"«ENDIF»
«ENDFOR»
«helpers.UserCode(dc.userCode1)»
+ typedef struct {
- typedef struct «dc.name»«IF dc.base!=null» /* extends -> inheritance not implemented yet */ «dc.base.name»«ENDIF» {
-
- «helpers.UserCode(dc.userCode2)»
-
+ «helpers.UserCode(dc.userCode2)»
+
«helpers.Attributes(dc.attributes)»
- «helpers.AttributeSettersGetters(dc.attributes)»
- «helpers.Operations(dc.operations)»
-
- // default constructor
- public «dc.name»() {
- «FOR a : dc.attributes»
- «IF a.defaultValueLiteral!=null»
- «IF a.size==0»«a.name» = «a.defaultValueLiteral»;«ENDIF»
- «ELSEIF a.type.type!=null»
- «a.name» = new «a.type.type.name»();
- «ENDIF»
- «ENDFOR»
- }
- // deep copy
- public «dc.name» deepCopy() {
- «dc.name» copy = new «dc.name»();
- «FOR a : dc.attributes»
- «IF a.type.type!=null»
- copy.«a.name» = «a.name».deepCopy();
- «ELSE»
- «IF a.size==0»copy.«a.name» = «a.name»;«ELSE»for (int i=0;i<«a.size»;i++){copy.«a.name»[i]=«a.name»[i];}«ENDIF»
- «ENDIF»
- «ENDFOR»
- return copy;
- }
- };
+ } «dc.name»«IF dc.base!=null» /* extends -> inheritance not implemented yet */ «dc.base.name»«ENDIF»;
+
+ // TODO: do we need setters and getters for C and C++ ?
+
+ «helpers.OperationsDeclaration(dc.operations, dc.name)»
+
+ // deep copy
+ void «dc.name»_deepCopy(«dc.name»* source, «dc.name»* target);
+
+ #endif /* _«dc.name»_H_ */
+
'''
}
def generateSourceFile(Root root, DataClass dc) {'''
- #include "«dc.getCHeaderFileName»";
+ #include "«dc.getCHeaderFileName»"
«helpers.UserCode(dc.userCode3)»
- // TODO
+ // TODO: do we need setters and getters for C and C++ ?
+
+ «helpers.OperationsImplementation(dc.operations, dc.name)»
+
+ #include <string.h>
+
+ // deep copy
+ void «dc.name»_deepCopy(«dc.name»* source, «dc.name»* target) {
+ memcpy(target, source, sizeof(«dc.name»));
+ }
+
+
'''}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/MainGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/MainGen.xtend
index 8ae420117..6dae1889d 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/MainGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/MainGen.xtend
@@ -41,12 +41,12 @@ class MainGen implements IGenerator {
def void doGenerate(Root e) {
dataClassGen.doGenerate(e);
- protocolClassGen.doGenerate(e);
- actorClassGen.doGenerate(e);
- subsystemClassGen.doGenerate(e);
+ //protocolClassGen.doGenerate(e);
+ //actorClassGen.doGenerate(e);
+ //subsystemClassGen.doGenerate(e);
if (!e.library) {
- subsystemRunnerGen.doGenerate(e);
+ //subsystemRunnerGen.doGenerate(e);
}
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
index 69fdbeeb8..c2d2041ee 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
@@ -151,7 +151,7 @@ class ProtocolClassGen {
«IF pclass!=null»
«helpers.Attributes(pclass.attributes)»
- «helpers.Operations(pclass.operations)»
+ «helpers.OperationsDeclaration(pclass.operations, name)»
«ENDIF»
// sent messages
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
index 9893cc2f4..0e43bb098 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
@@ -278,8 +278,9 @@ public class ActorClassGen {
_builder.newLineIfNotEmpty();
_builder.append("\t");
EList<Operation> _operations = ac.getOperations();
- StringConcatenation _Operations = this.helpers.Operations(_operations);
- _builder.append(_Operations, " ");
+ String _name_10 = ac.getName();
+ StringConcatenation _OperationsDeclaration = this.helpers.OperationsDeclaration(_operations, _name_10);
+ _builder.append(_OperationsDeclaration, " ");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
@@ -287,8 +288,8 @@ public class ActorClassGen {
_builder.newLine();
_builder.append("\t");
_builder.append("public ");
- String _name_10 = ac.getName();
- _builder.append(_name_10, " ");
+ String _name_11 = ac.getName();
+ _builder.append(_name_11, " ");
_builder.append("(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){");
_builder.newLineIfNotEmpty();
{
@@ -306,8 +307,8 @@ public class ActorClassGen {
}
_builder.append("\t\t");
_builder.append("setClassName(\"");
- String _name_11 = ac.getName();
- _builder.append(_name_11, " ");
+ String _name_12 = ac.getName();
+ _builder.append(_name_12, " ");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
@@ -323,8 +324,8 @@ public class ActorClassGen {
boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_defaultValueLiteral, null);
if (_operator_notEquals_1) {
_builder.append("\t\t");
- String _name_12 = a.getName();
- _builder.append(_name_12, " ");
+ String _name_13 = a.getName();
+ _builder.append(_name_13, " ");
_builder.append(" = ");
String _defaultValueLiteral_1 = a.getDefaultValueLiteral();
_builder.append(_defaultValueLiteral_1, " ");
@@ -336,13 +337,13 @@ public class ActorClassGen {
boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_type_1, null);
if (_operator_notEquals_2) {
_builder.append("\t\t");
- String _name_13 = a.getName();
- _builder.append(_name_13, " ");
+ String _name_14 = a.getName();
+ _builder.append(_name_14, " ");
_builder.append(" = new ");
Type _type_2 = a.getType();
DataClass _type_3 = _type_2.getType();
- String _name_14 = _type_3.getName();
- _builder.append(_name_14, " ");
+ String _name_15 = _type_3.getName();
+ _builder.append(_name_15, " ");
_builder.append("();");
_builder.newLineIfNotEmpty();
}
@@ -358,17 +359,17 @@ public class ActorClassGen {
List<Port> _endPorts_2 = this.roomExt.getEndPorts(ac);
for(final Port ep_2 : _endPorts_2) {
_builder.append("\t\t");
- String _name_15 = ep_2.getName();
- _builder.append(_name_15, " ");
+ String _name_16 = ep_2.getName();
+ _builder.append(_name_16, " ");
_builder.append(" = new ");
String _portClassName_3 = this.roomExt.getPortClassName(ep_2);
_builder.append(_portClassName_3, " ");
_builder.append("(this, \"");
- String _name_16 = ep_2.getName();
- _builder.append(_name_16, " ");
- _builder.append("\", IFITEM_");
String _name_17 = ep_2.getName();
_builder.append(_name_17, " ");
+ _builder.append("\", IFITEM_");
+ String _name_18 = ep_2.getName();
+ _builder.append(_name_18, " ");
_builder.append(", ");
{
int _multiplicity = ep_2.getMultiplicity();
@@ -378,8 +379,8 @@ public class ActorClassGen {
}
}
_builder.append("port_addr[IFITEM_");
- String _name_18 = ep_2.getName();
- _builder.append(_name_18, " ");
+ String _name_19 = ep_2.getName();
+ _builder.append(_name_19, " ");
_builder.append("]");
{
int _multiplicity_1 = ep_2.getMultiplicity();
@@ -389,8 +390,8 @@ public class ActorClassGen {
}
}
_builder.append(", peer_addr[IFITEM_");
- String _name_19 = ep_2.getName();
- _builder.append(_name_19, " ");
+ String _name_20 = ep_2.getName();
+ _builder.append(_name_20, " ");
_builder.append("]");
{
int _multiplicity_2 = ep_2.getMultiplicity();
@@ -410,23 +411,23 @@ public class ActorClassGen {
EList<SAPRef> _strSAPs_2 = ac.getStrSAPs();
for(final SAPRef sap_2 : _strSAPs_2) {
_builder.append("\t\t");
- String _name_20 = sap_2.getName();
- _builder.append(_name_20, " ");
+ String _name_21 = sap_2.getName();
+ _builder.append(_name_21, " ");
_builder.append(" = new ");
String _portClassName_4 = this.roomExt.getPortClassName(sap_2);
_builder.append(_portClassName_4, " ");
_builder.append("(this, \"");
- String _name_21 = sap_2.getName();
- _builder.append(_name_21, " ");
- _builder.append("\", IFITEM_");
String _name_22 = sap_2.getName();
_builder.append(_name_22, " ");
- _builder.append(", 0, port_addr[IFITEM_");
+ _builder.append("\", IFITEM_");
String _name_23 = sap_2.getName();
_builder.append(_name_23, " ");
- _builder.append("][0], peer_addr[IFITEM_");
+ _builder.append(", 0, port_addr[IFITEM_");
String _name_24 = sap_2.getName();
_builder.append(_name_24, " ");
+ _builder.append("][0], peer_addr[IFITEM_");
+ String _name_25 = sap_2.getName();
+ _builder.append(_name_25, " ");
_builder.append("][0]); ");
_builder.newLineIfNotEmpty();
}
@@ -439,27 +440,27 @@ public class ActorClassGen {
for(final ServiceImplementation svc_2 : _serviceImplementations_2) {
_builder.append("\t\t");
SPPRef _spp_3 = svc_2.getSpp();
- String _name_25 = _spp_3.getName();
- _builder.append(_name_25, " ");
+ String _name_26 = _spp_3.getName();
+ _builder.append(_name_26, " ");
_builder.append(" = new ");
String _portClassName_5 = this.roomExt.getPortClassName(svc_2);
_builder.append(_portClassName_5, " ");
_builder.append("(this, \"");
SPPRef _spp_4 = svc_2.getSpp();
- String _name_26 = _spp_4.getName();
- _builder.append(_name_26, " ");
+ String _name_27 = _spp_4.getName();
+ _builder.append(_name_27, " ");
_builder.append("\", IFITEM_");
SPPRef _spp_5 = svc_2.getSpp();
- String _name_27 = _spp_5.getName();
- _builder.append(_name_27, " ");
+ String _name_28 = _spp_5.getName();
+ _builder.append(_name_28, " ");
_builder.append(", port_addr[IFITEM_");
SPPRef _spp_6 = svc_2.getSpp();
- String _name_28 = _spp_6.getName();
- _builder.append(_name_28, " ");
+ String _name_29 = _spp_6.getName();
+ _builder.append(_name_29, " ");
_builder.append("], peer_addr[IFITEM_");
SPPRef _spp_7 = svc_2.getSpp();
- String _name_29 = _spp_7.getName();
- _builder.append(_name_29, " ");
+ String _name_30 = _spp_7.getName();
+ _builder.append(_name_30, " ");
_builder.append("]); ");
_builder.newLineIfNotEmpty();
}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
index 1e7123c35..19e4397b8 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
@@ -13,6 +13,7 @@ import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
import org.eclipse.etrice.generator.etricegen.TransitionChain;
import org.eclipse.etrice.generator.generic.ILanguageExtension;
import org.eclipse.etrice.generator.generic.LanguageGenerator;
+import org.eclipse.xtext.xbase.lib.ComparableExtensions;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.StringExtensions;
@@ -148,6 +149,40 @@ public class CExtensions implements ILanguageExtension {
return _typedData;
}
+ public String accessLevelPrivate() {
+ return "";
+ }
+
+ public String accessLevelProtected() {
+ return "";
+ }
+
+ public String accessLevelPublic() {
+ return "";
+ }
+
+ public String memberAccess() {
+ return "self->";
+ }
+
+ public String selfPointer(final String classname, final int argumentCount) {
+ String _xifexpression = null;
+ boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)argumentCount), ((Integer)0));
+ if (_operator_greaterThan) {
+ String _operator_plus = StringExtensions.operator_plus(classname, "* self, ");
+ _xifexpression = _operator_plus;
+ } else {
+ String _operator_plus_1 = StringExtensions.operator_plus(classname, "* self");
+ _xifexpression = _operator_plus_1;
+ }
+ return _xifexpression;
+ }
+
+ public String operationScope(final String classname, final boolean isDeclaration) {
+ String _operator_plus = StringExtensions.operator_plus(classname, "_");
+ return _operator_plus;
+ }
+
public String getCHeaderFileName(final RoomClass rc) {
String _name = rc.getName();
String _operator_plus = StringExtensions.operator_plus(_name, ".h");
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
index 928b64f37..805bfe6c7 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
@@ -2,13 +2,12 @@ package org.eclipse.etrice.generator.c.gen;
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import java.util.HashSet;
import org.eclipse.emf.common.util.EList;
import org.eclipse.etrice.core.room.Attribute;
import org.eclipse.etrice.core.room.DataClass;
import org.eclipse.etrice.core.room.DetailCode;
import org.eclipse.etrice.core.room.Operation;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.Type;
import org.eclipse.etrice.generator.base.ILogger;
import org.eclipse.etrice.generator.c.gen.CExtensions;
import org.eclipse.etrice.generator.etricegen.Root;
@@ -71,18 +70,36 @@ public class DataClassGen {
public StringConcatenation generateHeaderFile(final Root root, final DataClass dc) {
StringConcatenation _builder = new StringConcatenation();
- _builder.append("TODO: includes for C-Headers instead of Java imports");
+ _builder.append("#ifndef _");
+ String _name = dc.getName();
+ _builder.append(_name, "");
+ _builder.append("_H_");
+ _builder.newLineIfNotEmpty();
+ _builder.append("#define _");
+ String _name_1 = dc.getName();
+ _builder.append(_name_1, "");
+ _builder.append("_H_");
+ _builder.newLineIfNotEmpty();
_builder.newLine();
+ _builder.append("#include \"../../src/datatypes.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* TODO: includes only for used DataClasses, also for other models */");
_builder.newLine();
- EList<RoomModel> _referencedModels = root.getReferencedModels(dc);
- EList<RoomModel> models = _referencedModels;
- _builder.newLineIfNotEmpty();
{
- for(final RoomModel model : models) {
- _builder.append("//import ");
- String _name = model.getName();
- _builder.append(_name, "");
- _builder.append(".*;");
+ HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(dc);
+ for(final DataClass dataClass : _referencedDataClasses) {
+ {
+ String _name_2 = dataClass.getName();
+ String _name_3 = dc.getName();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_name_2, _name_3);
+ if (_operator_notEquals) {
+ _builder.append("#include \"");
+ String _name_4 = dataClass.getName();
+ _builder.append(_name_4, "");
+ _builder.append(".h\"");
+ }
+ }
_builder.newLineIfNotEmpty();
}
}
@@ -93,26 +110,13 @@ public class DataClassGen {
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.newLine();
+ _builder.append("typedef struct {");
_builder.newLine();
- _builder.append("typedef struct ");
- String _name_1 = dc.getName();
- _builder.append(_name_1, "");
- {
- DataClass _base = dc.getBase();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
- if (_operator_notEquals) {
- _builder.append(" /* extends -> inheritance not implemented yet */ ");
- DataClass _base_1 = dc.getBase();
- String _name_2 = _base_1.getName();
- _builder.append(_name_2, "");
- }
- }
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
_builder.newLine();
+ _builder.append("\t");
DetailCode _userCode2 = dc.getUserCode2();
StringConcatenation _UserCode_1 = this.helpers.UserCode(_userCode2);
- _builder.append(_UserCode_1, "");
+ _builder.append(_UserCode_1, " ");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
@@ -121,143 +125,51 @@ public class DataClassGen {
_builder.append(_Attributes, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
- EList<Attribute> _attributes_1 = dc.getAttributes();
- StringConcatenation _AttributeSettersGetters = this.helpers.AttributeSettersGetters(_attributes_1);
- _builder.append(_AttributeSettersGetters, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- EList<Operation> _operations = dc.getOperations();
- StringConcatenation _Operations = this.helpers.Operations(_operations);
- _builder.append(_Operations, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// default constructor");
_builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- String _name_3 = dc.getName();
- _builder.append(_name_3, " ");
- _builder.append("() {");
- _builder.newLineIfNotEmpty();
+ _builder.append("} ");
+ String _name_5 = dc.getName();
+ _builder.append(_name_5, "");
{
- EList<Attribute> _attributes_2 = dc.getAttributes();
- for(final Attribute a : _attributes_2) {
- {
- String _defaultValueLiteral = a.getDefaultValueLiteral();
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_defaultValueLiteral, null);
- if (_operator_notEquals_1) {
- _builder.append("\t\t");
- {
- int _size = a.getSize();
- boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_size), ((Integer)0));
- if (_operator_equals) {
- String _name_4 = a.getName();
- _builder.append(_name_4, " ");
- _builder.append(" = ");
- String _defaultValueLiteral_1 = a.getDefaultValueLiteral();
- _builder.append(_defaultValueLiteral_1, " ");
- _builder.append(";");
- }
- }
- _builder.newLineIfNotEmpty();
- } else {
- Type _type = a.getType();
- DataClass _type_1 = _type.getType();
- boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_type_1, null);
- if (_operator_notEquals_2) {
- _builder.append("\t\t");
- String _name_5 = a.getName();
- _builder.append(_name_5, " ");
- _builder.append(" = new ");
- Type _type_2 = a.getType();
- DataClass _type_3 = _type_2.getType();
- String _name_6 = _type_3.getName();
- _builder.append(_name_6, " ");
- _builder.append("();");
- _builder.newLineIfNotEmpty();
- }
- }
- }
+ DataClass _base = dc.getBase();
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_base, null);
+ if (_operator_notEquals_1) {
+ _builder.append(" /* extends -> inheritance not implemented yet */ ");
+ DataClass _base_1 = dc.getBase();
+ String _name_6 = _base_1.getName();
+ _builder.append(_name_6, "");
}
}
- _builder.append("\t");
- _builder.append("}");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
_builder.newLine();
- _builder.append("\t");
+ _builder.append("// TODO: do we need setters and getters for C and C++ ?");
_builder.newLine();
- _builder.append("\t");
- _builder.append("// deep copy");
_builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
+ EList<Operation> _operations = dc.getOperations();
String _name_7 = dc.getName();
- _builder.append(_name_7, " ");
- _builder.append(" deepCopy() {");
+ StringConcatenation _OperationsDeclaration = this.helpers.OperationsDeclaration(_operations, _name_7);
+ _builder.append(_OperationsDeclaration, "");
_builder.newLineIfNotEmpty();
- _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("// deep copy");
+ _builder.newLine();
+ _builder.append("void ");
String _name_8 = dc.getName();
- _builder.append(_name_8, " ");
- _builder.append(" copy = new ");
+ _builder.append(_name_8, "");
+ _builder.append("_deepCopy(");
String _name_9 = dc.getName();
- _builder.append(_name_9, " ");
- _builder.append("();");
+ _builder.append(_name_9, "");
+ _builder.append("* source, ");
+ String _name_10 = dc.getName();
+ _builder.append(_name_10, "");
+ _builder.append("* target);");
_builder.newLineIfNotEmpty();
- {
- EList<Attribute> _attributes_3 = dc.getAttributes();
- for(final Attribute a_1 : _attributes_3) {
- {
- Type _type_4 = a_1.getType();
- DataClass _type_5 = _type_4.getType();
- boolean _operator_notEquals_3 = ObjectExtensions.operator_notEquals(_type_5, null);
- if (_operator_notEquals_3) {
- _builder.append("\t\t");
- _builder.append("copy.");
- String _name_10 = a_1.getName();
- _builder.append(_name_10, " ");
- _builder.append(" = ");
- String _name_11 = a_1.getName();
- _builder.append(_name_11, " ");
- _builder.append(".deepCopy();");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t\t");
- {
- int _size_1 = a_1.getSize();
- boolean _operator_equals_1 = ObjectExtensions.operator_equals(((Integer)_size_1), ((Integer)0));
- if (_operator_equals_1) {
- _builder.append("copy.");
- String _name_12 = a_1.getName();
- _builder.append(_name_12, " ");
- _builder.append(" = ");
- String _name_13 = a_1.getName();
- _builder.append(_name_13, " ");
- _builder.append(";");
- } else {
- _builder.append("for (int i=0;i<");
- int _size_2 = a_1.getSize();
- _builder.append(_size_2, " ");
- _builder.append(";i++){copy.");
- String _name_14 = a_1.getName();
- _builder.append(_name_14, " ");
- _builder.append("[i]=");
- String _name_15 = a_1.getName();
- _builder.append(_name_15, " ");
- _builder.append("[i];}");
- }
- }
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.append("\t\t");
- _builder.append("return copy;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
_builder.newLine();
- _builder.append("};");
+ _builder.append("#endif /* _");
+ String _name_11 = dc.getName();
+ _builder.append(_name_11, "");
+ _builder.append("_H_ */");
+ _builder.newLineIfNotEmpty();
_builder.newLine();
return _builder;
}
@@ -267,7 +179,7 @@ public class DataClassGen {
_builder.append("#include \"");
String _cHeaderFileName = this.stdExt.getCHeaderFileName(dc);
_builder.append(_cHeaderFileName, "");
- _builder.append("\";");
+ _builder.append("\"");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.newLine();
@@ -276,7 +188,40 @@ public class DataClassGen {
_builder.append(_UserCode, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
- _builder.append("// TODO");
+ _builder.append("// TODO: do we need setters and getters for C and C++ ?");
+ _builder.newLine();
+ _builder.newLine();
+ EList<Operation> _operations = dc.getOperations();
+ String _name = dc.getName();
+ StringConcatenation _OperationsImplementation = this.helpers.OperationsImplementation(_operations, _name);
+ _builder.append(_OperationsImplementation, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include <string.h>");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("// deep copy");
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_1 = dc.getName();
+ _builder.append(_name_1, "");
+ _builder.append("_deepCopy(");
+ String _name_2 = dc.getName();
+ _builder.append(_name_2, "");
+ _builder.append("* source, ");
+ String _name_3 = dc.getName();
+ _builder.append(_name_3, "");
+ _builder.append("* target) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("memcpy(target, source, sizeof(");
+ String _name_4 = dc.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
_builder.newLine();
return _builder;
}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java
index ddbb7e3d4..42faa3c18 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java
@@ -49,13 +49,9 @@ public class MainGen implements IGenerator {
public void doGenerate(final Root e) {
this.dataClassGen.doGenerate(e);
- this.protocolClassGen.doGenerate(e);
- this.actorClassGen.doGenerate(e);
- this.subsystemClassGen.doGenerate(e);
boolean _isLibrary = e.isLibrary();
boolean _operator_not = BooleanExtensions.operator_not(_isLibrary);
if (_operator_not) {
- this.subsystemRunnerGen.doGenerate(e);
}
}
}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
index 66eb38bde..351602c74 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
@@ -427,8 +427,8 @@ public class ProtocolClassGen {
_builder.newLineIfNotEmpty();
_builder.append("\t");
EList<Operation> _operations = pclass.getOperations();
- StringConcatenation _Operations = this.helpers.Operations(_operations);
- _builder.append(_Operations, " ");
+ StringConcatenation _OperationsDeclaration = this.helpers.OperationsDeclaration(_operations, name);
+ _builder.append(_OperationsDeclaration, " ");
_builder.newLineIfNotEmpty();
}
}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend
index 611eb8f36..d30a162fb 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend
@@ -94,7 +94,7 @@ class ActorClassGen {
«ENDFOR»
«helpers.Attributes(ac.attributes)»
- «helpers.Operations(ac.operations)»
+ «helpers.OperationsImplementation(ac.operations, ac.name)»
//--------------------- construction
public «ac.name»(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/DataClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/DataClassGen.xtend
index d92693d48..c6056f8ab 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/DataClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/DataClassGen.xtend
@@ -56,8 +56,8 @@ class DataClassGen {
«helpers.UserCode(dc.userCode2)»
«helpers.Attributes(dc.attributes)»
- «helpers.AttributeSettersGetters(dc.attributes)»
- «helpers.Operations(dc.operations)»
+ «helpers.AttributeSettersGettersImplementation(dc.attributes, dc.name)»
+ «helpers.OperationsImplementation(dc.operations, dc.name)»
// default constructor
public «dc.name»() {
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
index b10ab5561..3dab1c833 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
@@ -94,7 +94,16 @@ class JavaExtensions implements ILanguageExtension {
return languageGen.getTypedData(m)
}
- // Specific
+ override String accessLevelPrivate(){"private "}
+ override String accessLevelProtected(){"protected "}
+ override String accessLevelPublic(){"public "}
+
+ override String memberAccess(){"this."}
+ override String selfPointer(String classname, int argumentCount){""}
+
+ override String operationScope(String classname, boolean isDeclaration){""}
+
+ // only for Java
def String getJavaFileName(RoomClass rc) {
return rc.name+".java";
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend
index b6f517112..34e078661 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend
@@ -151,7 +151,7 @@ class ProtocolClassGen {
«IF pclass!=null»
«helpers.Attributes(pclass.attributes)»
- «helpers.Operations(pclass.operations)»
+ «helpers.OperationsImplementation(pclass.operations, name)»
«ENDIF»
// sent messages
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
index 81280a30e..21914800c 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
@@ -278,8 +278,9 @@ public class ActorClassGen {
_builder.newLineIfNotEmpty();
_builder.append("\t");
EList<Operation> _operations = ac.getOperations();
- StringConcatenation _Operations = this.helpers.Operations(_operations);
- _builder.append(_Operations, " ");
+ String _name_10 = ac.getName();
+ StringConcatenation _OperationsImplementation = this.helpers.OperationsImplementation(_operations, _name_10);
+ _builder.append(_OperationsImplementation, " ");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
@@ -287,8 +288,8 @@ public class ActorClassGen {
_builder.newLine();
_builder.append("\t");
_builder.append("public ");
- String _name_10 = ac.getName();
- _builder.append(_name_10, " ");
+ String _name_11 = ac.getName();
+ _builder.append(_name_11, " ");
_builder.append("(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){");
_builder.newLineIfNotEmpty();
{
@@ -306,8 +307,8 @@ public class ActorClassGen {
}
_builder.append("\t\t");
_builder.append("setClassName(\"");
- String _name_11 = ac.getName();
- _builder.append(_name_11, " ");
+ String _name_12 = ac.getName();
+ _builder.append(_name_12, " ");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
@@ -323,8 +324,8 @@ public class ActorClassGen {
boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_defaultValueLiteral, null);
if (_operator_notEquals_1) {
_builder.append("\t\t");
- String _name_12 = a.getName();
- _builder.append(_name_12, " ");
+ String _name_13 = a.getName();
+ _builder.append(_name_13, " ");
_builder.append(" = ");
String _defaultValueLiteral_1 = a.getDefaultValueLiteral();
_builder.append(_defaultValueLiteral_1, " ");
@@ -336,13 +337,13 @@ public class ActorClassGen {
boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_type_1, null);
if (_operator_notEquals_2) {
_builder.append("\t\t");
- String _name_13 = a.getName();
- _builder.append(_name_13, " ");
+ String _name_14 = a.getName();
+ _builder.append(_name_14, " ");
_builder.append(" = new ");
Type _type_2 = a.getType();
DataClass _type_3 = _type_2.getType();
- String _name_14 = _type_3.getName();
- _builder.append(_name_14, " ");
+ String _name_15 = _type_3.getName();
+ _builder.append(_name_15, " ");
_builder.append("();");
_builder.newLineIfNotEmpty();
}
@@ -358,17 +359,17 @@ public class ActorClassGen {
List<Port> _endPorts_2 = this.roomExt.getEndPorts(ac);
for(final Port ep_2 : _endPorts_2) {
_builder.append("\t\t");
- String _name_15 = ep_2.getName();
- _builder.append(_name_15, " ");
+ String _name_16 = ep_2.getName();
+ _builder.append(_name_16, " ");
_builder.append(" = new ");
String _portClassName_3 = this.roomExt.getPortClassName(ep_2);
_builder.append(_portClassName_3, " ");
_builder.append("(this, \"");
- String _name_16 = ep_2.getName();
- _builder.append(_name_16, " ");
- _builder.append("\", IFITEM_");
String _name_17 = ep_2.getName();
_builder.append(_name_17, " ");
+ _builder.append("\", IFITEM_");
+ String _name_18 = ep_2.getName();
+ _builder.append(_name_18, " ");
_builder.append(", ");
{
int _multiplicity = ep_2.getMultiplicity();
@@ -378,8 +379,8 @@ public class ActorClassGen {
}
}
_builder.append("port_addr[IFITEM_");
- String _name_18 = ep_2.getName();
- _builder.append(_name_18, " ");
+ String _name_19 = ep_2.getName();
+ _builder.append(_name_19, " ");
_builder.append("]");
{
int _multiplicity_1 = ep_2.getMultiplicity();
@@ -389,8 +390,8 @@ public class ActorClassGen {
}
}
_builder.append(", peer_addr[IFITEM_");
- String _name_19 = ep_2.getName();
- _builder.append(_name_19, " ");
+ String _name_20 = ep_2.getName();
+ _builder.append(_name_20, " ");
_builder.append("]");
{
int _multiplicity_2 = ep_2.getMultiplicity();
@@ -410,23 +411,23 @@ public class ActorClassGen {
EList<SAPRef> _strSAPs_2 = ac.getStrSAPs();
for(final SAPRef sap_2 : _strSAPs_2) {
_builder.append("\t\t");
- String _name_20 = sap_2.getName();
- _builder.append(_name_20, " ");
+ String _name_21 = sap_2.getName();
+ _builder.append(_name_21, " ");
_builder.append(" = new ");
String _portClassName_4 = this.roomExt.getPortClassName(sap_2);
_builder.append(_portClassName_4, " ");
_builder.append("(this, \"");
- String _name_21 = sap_2.getName();
- _builder.append(_name_21, " ");
- _builder.append("\", IFITEM_");
String _name_22 = sap_2.getName();
_builder.append(_name_22, " ");
- _builder.append(", 0, port_addr[IFITEM_");
+ _builder.append("\", IFITEM_");
String _name_23 = sap_2.getName();
_builder.append(_name_23, " ");
- _builder.append("][0], peer_addr[IFITEM_");
+ _builder.append(", 0, port_addr[IFITEM_");
String _name_24 = sap_2.getName();
_builder.append(_name_24, " ");
+ _builder.append("][0], peer_addr[IFITEM_");
+ String _name_25 = sap_2.getName();
+ _builder.append(_name_25, " ");
_builder.append("][0]); ");
_builder.newLineIfNotEmpty();
}
@@ -439,27 +440,27 @@ public class ActorClassGen {
for(final ServiceImplementation svc_2 : _serviceImplementations_2) {
_builder.append("\t\t");
SPPRef _spp_3 = svc_2.getSpp();
- String _name_25 = _spp_3.getName();
- _builder.append(_name_25, " ");
+ String _name_26 = _spp_3.getName();
+ _builder.append(_name_26, " ");
_builder.append(" = new ");
String _portClassName_5 = this.roomExt.getPortClassName(svc_2);
_builder.append(_portClassName_5, " ");
_builder.append("(this, \"");
SPPRef _spp_4 = svc_2.getSpp();
- String _name_26 = _spp_4.getName();
- _builder.append(_name_26, " ");
+ String _name_27 = _spp_4.getName();
+ _builder.append(_name_27, " ");
_builder.append("\", IFITEM_");
SPPRef _spp_5 = svc_2.getSpp();
- String _name_27 = _spp_5.getName();
- _builder.append(_name_27, " ");
+ String _name_28 = _spp_5.getName();
+ _builder.append(_name_28, " ");
_builder.append(", port_addr[IFITEM_");
SPPRef _spp_6 = svc_2.getSpp();
- String _name_28 = _spp_6.getName();
- _builder.append(_name_28, " ");
+ String _name_29 = _spp_6.getName();
+ _builder.append(_name_29, " ");
_builder.append("], peer_addr[IFITEM_");
SPPRef _spp_7 = svc_2.getSpp();
- String _name_29 = _spp_7.getName();
- _builder.append(_name_29, " ");
+ String _name_30 = _spp_7.getName();
+ _builder.append(_name_30, " ");
_builder.append("]); ");
_builder.newLineIfNotEmpty();
}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
index b7cbf36a3..36c208628 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
@@ -117,13 +117,15 @@ public class DataClassGen {
_builder.newLineIfNotEmpty();
_builder.append("\t");
EList<Attribute> _attributes_1 = dc.getAttributes();
- StringConcatenation _AttributeSettersGetters = this.helpers.AttributeSettersGetters(_attributes_1);
- _builder.append(_AttributeSettersGetters, " ");
+ String _name_3 = dc.getName();
+ StringConcatenation _AttributeSettersGettersImplementation = this.helpers.AttributeSettersGettersImplementation(_attributes_1, _name_3);
+ _builder.append(_AttributeSettersGettersImplementation, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
EList<Operation> _operations = dc.getOperations();
- StringConcatenation _Operations = this.helpers.Operations(_operations);
- _builder.append(_Operations, " ");
+ String _name_4 = dc.getName();
+ StringConcatenation _OperationsImplementation = this.helpers.OperationsImplementation(_operations, _name_4);
+ _builder.append(_OperationsImplementation, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
@@ -132,8 +134,8 @@ public class DataClassGen {
_builder.newLine();
_builder.append("\t");
_builder.append("public ");
- String _name_3 = dc.getName();
- _builder.append(_name_3, " ");
+ String _name_5 = dc.getName();
+ _builder.append(_name_5, " ");
_builder.append("() {");
_builder.newLineIfNotEmpty();
{
@@ -148,8 +150,8 @@ public class DataClassGen {
int _size = a.getSize();
boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_size), ((Integer)0));
if (_operator_equals) {
- String _name_4 = a.getName();
- _builder.append(_name_4, " ");
+ String _name_6 = a.getName();
+ _builder.append(_name_6, " ");
_builder.append(" = ");
String _defaultValueLiteral_1 = a.getDefaultValueLiteral();
_builder.append(_defaultValueLiteral_1, " ");
@@ -163,13 +165,13 @@ public class DataClassGen {
boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_type_1, null);
if (_operator_notEquals_2) {
_builder.append("\t\t");
- String _name_5 = a.getName();
- _builder.append(_name_5, " ");
+ String _name_7 = a.getName();
+ _builder.append(_name_7, " ");
_builder.append(" = new ");
Type _type_2 = a.getType();
DataClass _type_3 = _type_2.getType();
- String _name_6 = _type_3.getName();
- _builder.append(_name_6, " ");
+ String _name_8 = _type_3.getName();
+ _builder.append(_name_8, " ");
_builder.append("();");
_builder.newLineIfNotEmpty();
}
@@ -187,16 +189,16 @@ public class DataClassGen {
_builder.newLine();
_builder.append("\t");
_builder.append("public ");
- String _name_7 = dc.getName();
- _builder.append(_name_7, " ");
+ String _name_9 = dc.getName();
+ _builder.append(_name_9, " ");
_builder.append(" deepCopy() {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
- String _name_8 = dc.getName();
- _builder.append(_name_8, " ");
+ String _name_10 = dc.getName();
+ _builder.append(_name_10, " ");
_builder.append(" copy = new ");
- String _name_9 = dc.getName();
- _builder.append(_name_9, " ");
+ String _name_11 = dc.getName();
+ _builder.append(_name_11, " ");
_builder.append("();");
_builder.newLineIfNotEmpty();
{
@@ -209,11 +211,11 @@ public class DataClassGen {
if (_operator_notEquals_3) {
_builder.append("\t\t");
_builder.append("copy.");
- String _name_10 = a_1.getName();
- _builder.append(_name_10, " ");
+ String _name_12 = a_1.getName();
+ _builder.append(_name_12, " ");
_builder.append(" = ");
- String _name_11 = a_1.getName();
- _builder.append(_name_11, " ");
+ String _name_13 = a_1.getName();
+ _builder.append(_name_13, " ");
_builder.append(".deepCopy();");
_builder.newLineIfNotEmpty();
} else {
@@ -223,22 +225,22 @@ public class DataClassGen {
boolean _operator_equals_1 = ObjectExtensions.operator_equals(((Integer)_size_1), ((Integer)0));
if (_operator_equals_1) {
_builder.append("copy.");
- String _name_12 = a_1.getName();
- _builder.append(_name_12, " ");
+ String _name_14 = a_1.getName();
+ _builder.append(_name_14, " ");
_builder.append(" = ");
- String _name_13 = a_1.getName();
- _builder.append(_name_13, " ");
+ String _name_15 = a_1.getName();
+ _builder.append(_name_15, " ");
_builder.append(";");
} else {
_builder.append("for (int i=0;i<");
int _size_2 = a_1.getSize();
_builder.append(_size_2, " ");
_builder.append(";i++){copy.");
- String _name_14 = a_1.getName();
- _builder.append(_name_14, " ");
+ String _name_16 = a_1.getName();
+ _builder.append(_name_16, " ");
_builder.append("[i]=");
- String _name_15 = a_1.getName();
- _builder.append(_name_15, " ");
+ String _name_17 = a_1.getName();
+ _builder.append(_name_17, " ");
_builder.append("[i];}");
}
}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
index 246646cbc..356494208 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
@@ -209,6 +209,30 @@ public class JavaExtensions implements ILanguageExtension {
return _typedData;
}
+ public String accessLevelPrivate() {
+ return "private ";
+ }
+
+ public String accessLevelProtected() {
+ return "protected ";
+ }
+
+ public String accessLevelPublic() {
+ return "public ";
+ }
+
+ public String memberAccess() {
+ return "this.";
+ }
+
+ public String selfPointer(final String classname, final int argumentCount) {
+ return "";
+ }
+
+ public String operationScope(final String classname, final boolean isDeclaration) {
+ return "";
+ }
+
public String getJavaFileName(final RoomClass rc) {
String _name = rc.getName();
String _operator_plus = StringExtensions.operator_plus(_name, ".java");
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java
index a38eaab97..73d167105 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java
@@ -427,8 +427,8 @@ public class ProtocolClassGen {
_builder.newLineIfNotEmpty();
_builder.append("\t");
EList<Operation> _operations = pclass.getOperations();
- StringConcatenation _Operations = this.helpers.Operations(_operations);
- _builder.append(_Operations, " ");
+ StringConcatenation _OperationsImplementation = this.helpers.OperationsImplementation(_operations, name);
+ _builder.append(_OperationsImplementation, " ");
_builder.newLineIfNotEmpty();
}
}
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/ETriceGenPackage.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/ETriceGenPackage.java
index cb86aa397..9dd28e19b 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/ETriceGenPackage.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/ETriceGenPackage.java
@@ -1403,6 +1403,15 @@ public interface ETriceGenPackage extends EPackage {
int EXPANDED_ACTOR_CLASS__USER_CODE2 = RoomPackage.ACTOR_CLASS__USER_CODE2;
/**
+ * The feature id for the '<em><b>User Code3</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int EXPANDED_ACTOR_CLASS__USER_CODE3 = RoomPackage.ACTOR_CLASS__USER_CODE3;
+
+ /**
* The feature id for the '<em><b>Actor Refs</b></em>' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/Root.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/Root.java
index ea3684d28..5707b2cac 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/Root.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/Root.java
@@ -6,6 +6,8 @@
*/
package org.eclipse.etrice.generator.etricegen;
+import java.util.HashSet;
+
import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.DataClass;
import org.eclipse.etrice.core.room.ProtocolClass;
@@ -211,5 +213,7 @@ public interface Root extends EObject {
* @generated
*/
EList<ProtocolClass> getReferencedProtocols(ActorClass cls);
+
+ HashSet<DataClass> getReferencedDataClasses(DataClass cls);
} // Root
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/impl/RootImpl.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/impl/RootImpl.java
index 7a1545085..d97877ebf 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/impl/RootImpl.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/impl/RootImpl.java
@@ -715,5 +715,14 @@ public class RootImpl extends EObjectImpl implements Root {
dataClasses.add(attr.getType().getType());
}
}
+
+ // TODO: is this the correct place?
+ public HashSet<DataClass> getReferencedDataClasses(DataClass cls){
+ HashSet<DataClass> dataClasses = new HashSet<DataClass>();
+ getAttributeDataClasses(dataClasses, cls.getAttributes());
+ getOperationDataClasses(dataClasses, cls.getOperations());
+ return dataClasses;
+ }
+
} //RootImpl
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/util/ETriceGenSwitch.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/util/ETriceGenSwitch.java
index 0efec7f16..2aaf675cf 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/util/ETriceGenSwitch.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/util/ETriceGenSwitch.java
@@ -13,6 +13,7 @@ import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.ActorContainerClass;
import org.eclipse.etrice.core.room.RoomClass;
import org.eclipse.etrice.core.room.StructureClass;
+import org.eclipse.etrice.generator.etricegen.*;
import org.eclipse.etrice.generator.etricegen.ActiveTrigger;
import org.eclipse.etrice.generator.etricegen.ActorInstance;
import org.eclipse.etrice.generator.etricegen.BindingInstance;
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java
index 7f53df87d..65120bf5b 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java
@@ -17,4 +17,43 @@ public interface ILanguageExtension{
String defaultValue(PrimitiveType prim);
String defaultValue(TypedID a);
String getTypedDataDefinition(Message m);
+
+ /**
+ * unification of access level for all Languages before each member
+ * @return e.g. "private " for Java, nothing for C and C++ (no access level before the individual member)
+ */
+ String accessLevelPrivate();
+ /**
+ * unification of access level for all Languages before each member
+ * @return e.g. "protected " for Java, nothing for C and C++ (no access level before the individual member)
+ */
+ String accessLevelProtected();
+ /**
+ * unification of access level for all Languages before each member
+ * @return e.g. "public " for Java, nothing for C and C++ (no access level before the individual member)
+ */
+ String accessLevelPublic();
+
+ // Strings for member access
+
+ /**
+ * unification of member access for different languages
+ * @return e.g. "this." for Java and C++ or "self->" for C
+ */
+ String memberAccess();
+
+ /**
+ * self pointer for building class mechanism in C,
+ * e.g. MyClass_function1(MyClass *self, int32 argument1)
+ * @return "classname *self, " for C / for Java and C++ nothing
+ */
+ String selfPointer(String classname, int argumentCount);
+
+ /**
+ * language specific scoping string for operations
+ * e.g. nothing in Java (only inside class declaration), nothing and classname:: for C++ and classname_ for C
+ * @return "classname *self, " for C / for Java and C++ nothing
+ */
+ String operationScope(String classname, boolean isDeclaration);
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend
index 013841fe2..f2dc9c086 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend
@@ -36,32 +36,65 @@ class ProcedureHelpers {
'''
}
+ // Attributes
def Attributes(List<Attribute> attribs) {'''
//--------------------- attributes
- «FOR attribute : attribs»«IF attribute.size==0»protected «IF attribute.type.ext != null»«attribute.type.ext»«ELSE»«attribute.type.typeName()»«ENDIF» «attribute.name»;«ELSE»protected «attribute.type.typeName()»[] «attribute.name»«IF attribute.defaultValueLiteral==null» =new «attribute.type.typeName()»[«attribute.size»];«ELSE» = «attribute.defaultValueLiteral»;«ENDIF»
- «ENDIF»
+ «FOR attribute : attribs»
+ «IF attribute.size==0»«languageExt.accessLevelProtected()»«IF attribute.type.ext != null»«attribute.type.ext»«ELSE»«attribute.type.typeName()»«ENDIF» «attribute.name»;
+ «ELSE»«languageExt.accessLevelProtected()»«attribute.type.typeName()»[] «attribute.name»«IF attribute.defaultValueLiteral==null» =new «attribute.type.typeName()»[«attribute.size»];«ELSE» = «attribute.defaultValueLiteral»;«ENDIF»
+ «ENDIF»
«ENDFOR»
'''
}
- def AttributeSettersGetters(List<Attribute> attribs) {'''
+ // Attribute setters & getters
+ def AttributeSettersGettersDeclaration(List<Attribute> attribs, String classname) {'''
//--------------------- attribute setters and getters
- «FOR attribute : attribs»public void set«attribute.name.toFirstUpper()» («IF attribute.type.ext != null» «attribute.type.ext»«ELSE»«attribute.type.typeName()»«ENDIF»«IF attribute.size!=0»[]«ENDIF» «attribute.name») {
- this.«attribute.name» = «attribute.name»;
+ «FOR attribute : attribs»
+ «SetterHeader(attribute, classname)»;
+ «GetterHeader(attribute, classname)»;
+ «ENDFOR»
+ '''
+ }
+
+ def AttributeSettersGettersImplementation(List<Attribute> attribs, String classname) {'''
+ //--------------------- attribute setters and getters
+ «FOR attribute : attribs»«SetterHeader(attribute, classname)» {
+ «languageExt.memberAccess()»«attribute.name» = «attribute.name»;
}
- public «IF attribute.type.ext != null» «attribute.type.ext»«ELSE»«attribute.type.typeName()»«ENDIF»«IF attribute.size!=0»[]«ENDIF» get«attribute.name.toFirstUpper()» () {
- return «attribute.name»;
+ «GetterHeader(attribute, classname)» {
+ return «languageExt.memberAccess()»«attribute.name»;
}«ENDFOR»
'''
}
+
+ def private SetterHeader(Attribute attribute, String classname){'''
+ «languageExt.accessLevelPublic()»void set«attribute.name.toFirstUpper()» («languageExt.selfPointer(classname, 1)»«IF attribute.type.ext != null» «attribute.type.ext»«ELSE»«attribute.type.typeName()»«ENDIF»«IF attribute.size!=0»[]«ENDIF» «attribute.name»)'''
+ }
+ def private GetterHeader(Attribute attribute, String classname){'''
+ «languageExt.accessLevelPublic()»«IF attribute.type.ext != null» «attribute.type.ext»«ELSE»«attribute.type.typeName()»«ENDIF»«IF attribute.size!=0»[]«ENDIF» get«attribute.name.toFirstUpper()» («languageExt.selfPointer(classname, 0)»)'''
+ }
- def Operations(List<Operation> operations) {'''
+
+ // Operations
+ def OperationsDeclaration(List<Operation> operations, String classname) {'''
+ //--------------------- operations
+ «FOR operation : operations»«OperationHeader(operation, classname, true)»;
+ «ENDFOR»
+ '''
+ }
+
+ def OperationsImplementation(List<Operation> operations, String classname) {'''
//--------------------- operations
- «FOR operation : operations»public «IF operation.returntype==null»void«ELSE»«operation.returntype.freeTypeName()»«ENDIF» «operation.name» («FOR argument : operation.arguments SEPARATOR ", "»«argument.type.freeTypeName()» «argument.name»«ENDFOR»){
- «FOR command : operation.detailCode.commands» «command»
+ «FOR operation : operations»«OperationHeader(operation, classname, false)»{
+ «FOR command : operation.detailCode.commands» «command»
«ENDFOR»
}«ENDFOR»
'''
}
+ def private OperationHeader(Operation operation, String classname, boolean isDeclaration) {'''
+ «languageExt.accessLevelProtected()»«IF operation.returntype==null»void«ELSE»«operation.returntype.freeTypeName()»«ENDIF» «languageExt.operationScope(classname, isDeclaration)»«operation.name» («languageExt.selfPointer(classname, operation.arguments.size)»«FOR argument : operation.arguments SEPARATOR ", "»«argument.type.freeTypeName()» «argument.name»«ENDFOR»)'''
+ }
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java
index fdb80eb50..7f690ffbf 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java
@@ -53,7 +53,8 @@ public class ProcedureHelpers {
int _size = attribute.getSize();
boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_size), ((Integer)0));
if (_operator_equals) {
- _builder.append("protected ");
+ String _accessLevelProtected = this.languageExt.accessLevelProtected();
+ _builder.append(_accessLevelProtected, "");
{
Type _type = attribute.getType();
String _ext = _type.getExt();
@@ -72,8 +73,10 @@ public class ProcedureHelpers {
String _name = attribute.getName();
_builder.append(_name, "");
_builder.append(";");
+ _builder.newLineIfNotEmpty();
} else {
- _builder.append("protected ");
+ String _accessLevelProtected_1 = this.languageExt.accessLevelProtected();
+ _builder.append(_accessLevelProtected_1, "");
Type _type_3 = attribute.getType();
String _typeName_1 = this.languageExt.typeName(_type_3);
_builder.append(_typeName_1, "");
@@ -107,88 +110,57 @@ public class ProcedureHelpers {
return _builder;
}
- public StringConcatenation AttributeSettersGetters(final List<Attribute> attribs) {
+ public StringConcatenation AttributeSettersGettersDeclaration(final List<Attribute> attribs, final String classname) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("//--------------------- attribute setters and getters");
_builder.newLine();
{
for(final Attribute attribute : attribs) {
- _builder.append("public void set");
- String _name = attribute.getName();
- String _firstUpper = StringExtensions.toFirstUpper(_name);
- _builder.append(_firstUpper, "");
- _builder.append(" (");
- {
- Type _type = attribute.getType();
- String _ext = _type.getExt();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_ext, null);
- if (_operator_notEquals) {
- _builder.append(" ");
- Type _type_1 = attribute.getType();
- String _ext_1 = _type_1.getExt();
- _builder.append(_ext_1, "");
- } else {
- Type _type_2 = attribute.getType();
- String _typeName = this.languageExt.typeName(_type_2);
- _builder.append(_typeName, "");
- }
- }
- {
- int _size = attribute.getSize();
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(((Integer)_size), ((Integer)0));
- if (_operator_notEquals_1) {
- _builder.append("[]");
- }
- }
- _builder.append(" ");
- String _name_1 = attribute.getName();
- _builder.append(_name_1, "");
- _builder.append(") {");
+ StringConcatenation _SetterHeader = this.SetterHeader(attribute, classname);
+ _builder.append(_SetterHeader, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ StringConcatenation _GetterHeader = this.GetterHeader(attribute, classname);
+ _builder.append(_GetterHeader, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ public StringConcatenation AttributeSettersGettersImplementation(final List<Attribute> attribs, final String classname) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("//--------------------- attribute setters and getters");
+ _builder.newLine();
+ {
+ for(final Attribute attribute : attribs) {
+ StringConcatenation _SetterHeader = this.SetterHeader(attribute, classname);
+ _builder.append(_SetterHeader, "");
+ _builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("\t ");
- _builder.append("this.");
- String _name_2 = attribute.getName();
- _builder.append(_name_2, " ");
+ String _memberAccess = this.languageExt.memberAccess();
+ _builder.append(_memberAccess, " ");
+ String _name = attribute.getName();
+ _builder.append(_name, " ");
_builder.append(" = ");
- String _name_3 = attribute.getName();
- _builder.append(_name_3, " ");
+ String _name_1 = attribute.getName();
+ _builder.append(_name_1, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
- _builder.append("public ");
- {
- Type _type_3 = attribute.getType();
- String _ext_2 = _type_3.getExt();
- boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_ext_2, null);
- if (_operator_notEquals_2) {
- _builder.append(" ");
- Type _type_4 = attribute.getType();
- String _ext_3 = _type_4.getExt();
- _builder.append(_ext_3, "");
- } else {
- Type _type_5 = attribute.getType();
- String _typeName_1 = this.languageExt.typeName(_type_5);
- _builder.append(_typeName_1, "");
- }
- }
- {
- int _size_1 = attribute.getSize();
- boolean _operator_notEquals_3 = ObjectExtensions.operator_notEquals(((Integer)_size_1), ((Integer)0));
- if (_operator_notEquals_3) {
- _builder.append("[]");
- }
- }
- _builder.append(" get");
- String _name_4 = attribute.getName();
- String _firstUpper_1 = StringExtensions.toFirstUpper(_name_4);
- _builder.append(_firstUpper_1, "");
- _builder.append(" () {");
+ StringConcatenation _GetterHeader = this.GetterHeader(attribute, classname);
+ _builder.append(_GetterHeader, "");
+ _builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("return ");
- String _name_5 = attribute.getName();
- _builder.append(_name_5, " ");
+ String _memberAccess_1 = this.languageExt.memberAccess();
+ _builder.append(_memberAccess_1, " ");
+ String _name_2 = attribute.getName();
+ _builder.append(_name_2, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.append("}");
@@ -198,54 +170,114 @@ public class ProcedureHelpers {
return _builder;
}
- public StringConcatenation Operations(final List<Operation> operations) {
+ private StringConcatenation SetterHeader(final Attribute attribute, final String classname) {
+ StringConcatenation _builder = new StringConcatenation();
+ String _accessLevelPublic = this.languageExt.accessLevelPublic();
+ _builder.append(_accessLevelPublic, "");
+ _builder.append("void set");
+ String _name = attribute.getName();
+ String _firstUpper = StringExtensions.toFirstUpper(_name);
+ _builder.append(_firstUpper, "");
+ _builder.append(" (");
+ String _selfPointer = this.languageExt.selfPointer(classname, 1);
+ _builder.append(_selfPointer, "");
+ {
+ Type _type = attribute.getType();
+ String _ext = _type.getExt();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_ext, null);
+ if (_operator_notEquals) {
+ _builder.append(" ");
+ Type _type_1 = attribute.getType();
+ String _ext_1 = _type_1.getExt();
+ _builder.append(_ext_1, "");
+ } else {
+ Type _type_2 = attribute.getType();
+ String _typeName = this.languageExt.typeName(_type_2);
+ _builder.append(_typeName, "");
+ }
+ }
+ {
+ int _size = attribute.getSize();
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(((Integer)_size), ((Integer)0));
+ if (_operator_notEquals_1) {
+ _builder.append("[]");
+ }
+ }
+ _builder.append(" ");
+ String _name_1 = attribute.getName();
+ _builder.append(_name_1, "");
+ _builder.append(")");
+ return _builder;
+ }
+
+ private StringConcatenation GetterHeader(final Attribute attribute, final String classname) {
+ StringConcatenation _builder = new StringConcatenation();
+ String _accessLevelPublic = this.languageExt.accessLevelPublic();
+ _builder.append(_accessLevelPublic, "");
+ {
+ Type _type = attribute.getType();
+ String _ext = _type.getExt();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_ext, null);
+ if (_operator_notEquals) {
+ _builder.append(" ");
+ Type _type_1 = attribute.getType();
+ String _ext_1 = _type_1.getExt();
+ _builder.append(_ext_1, "");
+ } else {
+ Type _type_2 = attribute.getType();
+ String _typeName = this.languageExt.typeName(_type_2);
+ _builder.append(_typeName, "");
+ }
+ }
+ {
+ int _size = attribute.getSize();
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(((Integer)_size), ((Integer)0));
+ if (_operator_notEquals_1) {
+ _builder.append("[]");
+ }
+ }
+ _builder.append(" get");
+ String _name = attribute.getName();
+ String _firstUpper = StringExtensions.toFirstUpper(_name);
+ _builder.append(_firstUpper, "");
+ _builder.append(" (");
+ String _selfPointer = this.languageExt.selfPointer(classname, 0);
+ _builder.append(_selfPointer, "");
+ _builder.append(")");
+ return _builder;
+ }
+
+ public StringConcatenation OperationsDeclaration(final List<Operation> operations, final String classname) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("//--------------------- operations");
_builder.newLine();
{
for(final Operation operation : operations) {
- _builder.append("public ");
- {
- FreeType _returntype = operation.getReturntype();
- boolean _operator_equals = ObjectExtensions.operator_equals(_returntype, null);
- if (_operator_equals) {
- _builder.append("void");
- } else {
- FreeType _returntype_1 = operation.getReturntype();
- String _freeTypeName = this.languageExt.freeTypeName(_returntype_1);
- _builder.append(_freeTypeName, "");
- }
- }
- _builder.append(" ");
- String _name = operation.getName();
- _builder.append(_name, "");
- _builder.append(" (");
- {
- EList<FreeTypedID> _arguments = operation.getArguments();
- boolean hasAnyElements = false;
- for(final FreeTypedID argument : _arguments) {
- if (!hasAnyElements) {
- hasAnyElements = true;
- } else {
- _builder.appendImmediate(", ", "");
- }
- FreeType _type = argument.getType();
- String _freeTypeName_1 = this.languageExt.freeTypeName(_type);
- _builder.append(_freeTypeName_1, "");
- _builder.append(" ");
- String _name_1 = argument.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append("){");
+ StringConcatenation _OperationHeader = this.OperationHeader(operation, classname, true);
+ _builder.append(_OperationHeader, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ public StringConcatenation OperationsImplementation(final List<Operation> operations, final String classname) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("//--------------------- operations");
+ _builder.newLine();
+ {
+ for(final Operation operation : operations) {
+ StringConcatenation _OperationHeader = this.OperationHeader(operation, classname, false);
+ _builder.append(_OperationHeader, "");
+ _builder.append("{");
_builder.newLineIfNotEmpty();
- _builder.append("\t");
{
DetailCode _detailCode = operation.getDetailCode();
EList<String> _commands = _detailCode.getCommands();
for(final String command : _commands) {
_builder.append("\t");
- _builder.append(command, " ");
+ _builder.append(command, "");
_builder.newLineIfNotEmpty();
}
}
@@ -255,4 +287,50 @@ public class ProcedureHelpers {
_builder.newLineIfNotEmpty();
return _builder;
}
+
+ private StringConcatenation OperationHeader(final Operation operation, final String classname, final boolean isDeclaration) {
+ StringConcatenation _builder = new StringConcatenation();
+ String _accessLevelProtected = this.languageExt.accessLevelProtected();
+ _builder.append(_accessLevelProtected, "");
+ {
+ FreeType _returntype = operation.getReturntype();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_returntype, null);
+ if (_operator_equals) {
+ _builder.append("void");
+ } else {
+ FreeType _returntype_1 = operation.getReturntype();
+ String _freeTypeName = this.languageExt.freeTypeName(_returntype_1);
+ _builder.append(_freeTypeName, "");
+ }
+ }
+ _builder.append(" ");
+ String _operationScope = this.languageExt.operationScope(classname, isDeclaration);
+ _builder.append(_operationScope, "");
+ String _name = operation.getName();
+ _builder.append(_name, "");
+ _builder.append(" (");
+ EList<FreeTypedID> _arguments = operation.getArguments();
+ int _size = _arguments.size();
+ String _selfPointer = this.languageExt.selfPointer(classname, _size);
+ _builder.append(_selfPointer, "");
+ {
+ EList<FreeTypedID> _arguments_1 = operation.getArguments();
+ boolean hasAnyElements = false;
+ for(final FreeTypedID argument : _arguments_1) {
+ if (!hasAnyElements) {
+ hasAnyElements = true;
+ } else {
+ _builder.appendImmediate(", ", "");
+ }
+ FreeType _type = argument.getType();
+ String _freeTypeName_1 = this.languageExt.freeTypeName(_type);
+ _builder.append(_freeTypeName_1, "");
+ _builder.append(" ");
+ String _name_1 = argument.getName();
+ _builder.append(_name_1, "");
+ }
+ }
+ _builder.append(")");
+ return _builder;
+ }
}
diff --git a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/ATimingService.java b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/ATimingService.java
index 8e058b4ad..244da204a 100644
--- a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/ATimingService.java
+++ b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/ATimingService.java
@@ -37,8 +37,8 @@ public class ATimingService extends ActorClassBase {
//--------------------- attributes
//--------------------- operations
- public void stop (){
- System.out.println(toString() + "::stop()");
+ protected void stop (){
+ System.out.println(toString() + "::stop()");
timerService.cancel();
timerService = null;
}
diff --git a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimeout.java b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimeout.java
index 68208bd89..d7c4add53 100644
--- a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimeout.java
+++ b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimeout.java
@@ -135,13 +135,13 @@ public class PTimeout {
//--------------------- attributes
//--------------------- operations
- public void timeout (Integer id){
- //regular PortClass Operation timeout
- DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
- getPeerAddress(), messageStrings[OUT_timeoutTick]);
-
- getPeerMsgReceiver().receive(
- new EventWithDataMessage(getPeerAddress(), OUT_timeoutTick, id));
+ protected void timeout (Integer id){
+ //regular PortClass Operation timeout
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(), messageStrings[OUT_timeoutTick]);
+
+ getPeerMsgReceiver().receive(
+ new EventWithDataMessage(getPeerAddress(), OUT_timeoutTick, id));
}
// sent messages
diff --git a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimer.java b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimer.java
index 5afca4178..e7c5dd21a 100644
--- a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimer.java
+++ b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimer.java
@@ -135,13 +135,13 @@ public class PTimer {
//--------------------- attributes
//--------------------- operations
- public void timer (Integer id){
- //regular PortClass Operation timer
- DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
- getPeerAddress(), messageStrings[OUT_timerTick]);
-
- getPeerMsgReceiver().receive(
- new EventWithDataMessage(getPeerAddress(), OUT_timerTick, id));
+ protected void timer (Integer id){
+ //regular PortClass Operation timer
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(), messageStrings[OUT_timerTick]);
+
+ getPeerMsgReceiver().receive(
+ new EventWithDataMessage(getPeerAddress(), OUT_timerTick, id));
}
// sent messages
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPingActor.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPingActor.java
index 8432a064b..72149f301 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPingActor.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPingActor.java
@@ -36,7 +36,8 @@ public class MrPingActor extends ActorClassBase {
protected static final int IFITEM_timer = 4;
//--------------------- attributes
- protected int count;protected int pongCount;
+ protected int count;
+ protected int pongCount;
//--------------------- operations
//--------------------- construction
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPingActor.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPingActor.java
index aaee8dcc5..17f6d3087 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPingActor.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPingActor.java
@@ -32,7 +32,8 @@ public class MrPingActor extends ActorClassBase {
protected static final int IFITEM_timer = 2;
//--------------------- attributes
- protected int count;protected int pongCount;
+ protected int count;
+ protected int pongCount;
//--------------------- operations
//--------------------- construction
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPing.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPing.java
index 308f77f35..06d21d088 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPing.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPing.java
@@ -35,8 +35,8 @@ public class MrPing extends ActorClassBase {
protected int[] i32Array =new int[10];
protected PingPongData data;
//--------------------- operations
- public void printData (PingPongData d){
- System.out.printf("MrPing:\n");
+ protected void printData (PingPongData d){
+ System.out.printf("MrPing:\n");
System.out.printf("i8Val: %d \n",d.getI8Val());
System.out.printf("i16Val: %d \n",d.getI16Val());
System.out.printf("i32Val: %d \n",d.getI32Val());
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPong.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPong.java
index 5b5a74cd4..20f785edb 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPong.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPong.java
@@ -26,8 +26,8 @@ public class MrPong extends ActorClassBase {
//--------------------- attributes
//--------------------- operations
- public void printData (PingPongData d){
- System.out.printf("\n");
+ protected void printData (PingPongData d){
+ System.out.printf("\n");
System.out.printf("i8Val: %d \n",d.getI8Val());
System.out.printf("i16Val: %d \n",d.getI16Val());
System.out.printf("i32Val: %d \n",d.getI32Val());
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/PingPongData.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/PingPongData.java
index 30952af53..e7db2e999 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/PingPongData.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/PingPongData.java
@@ -7,54 +7,61 @@ public class PingPongData {
//--------------------- attributes
- protected byte i8Val;protected short i16Val;protected int i32Val;protected char charVal;protected float f32Val;protected double f64Val;protected String stringVal;protected int[] arrayFromInt32 = {1,2,3,4,5};
+ protected byte i8Val;
+ protected short i16Val;
+ protected int i32Val;
+ protected char charVal;
+ protected float f32Val;
+ protected double f64Val;
+ protected String stringVal;
+ protected int[] arrayFromInt32 = {1,2,3,4,5};
protected PingPongDataDeep ownType;
//--------------------- attribute setters and getters
public void setI8Val (byte i8Val) {
this.i8Val = i8Val;
}
public byte getI8Val () {
- return i8Val;
+ return this.i8Val;
}public void setI16Val (short i16Val) {
this.i16Val = i16Val;
}
public short getI16Val () {
- return i16Val;
+ return this.i16Val;
}public void setI32Val (int i32Val) {
this.i32Val = i32Val;
}
public int getI32Val () {
- return i32Val;
+ return this.i32Val;
}public void setCharVal (char charVal) {
this.charVal = charVal;
}
public char getCharVal () {
- return charVal;
+ return this.charVal;
}public void setF32Val (float f32Val) {
this.f32Val = f32Val;
}
public float getF32Val () {
- return f32Val;
+ return this.f32Val;
}public void setF64Val (double f64Val) {
this.f64Val = f64Val;
}
public double getF64Val () {
- return f64Val;
+ return this.f64Val;
}public void setStringVal (String stringVal) {
this.stringVal = stringVal;
}
public String getStringVal () {
- return stringVal;
+ return this.stringVal;
}public void setArrayFromInt32 (int[] arrayFromInt32) {
this.arrayFromInt32 = arrayFromInt32;
}
public int[] getArrayFromInt32 () {
- return arrayFromInt32;
+ return this.arrayFromInt32;
}public void setOwnType (PingPongDataDeep ownType) {
this.ownType = ownType;
}
public PingPongDataDeep getOwnType () {
- return ownType;
+ return this.ownType;
}
//--------------------- operations
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/PingPongDataDeep.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/PingPongDataDeep.java
index 6cf9acb72..9d0928824 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/PingPongDataDeep.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/PingPongDataDeep.java
@@ -7,48 +7,55 @@ public class PingPongDataDeep {
//--------------------- attributes
- protected byte i8Val;protected short i16Val;protected int i32Val;protected char charVal;protected float f32Val;protected double f64Val;protected String stringVal;protected int[] arrayFromInt32 =new int[10];
+ protected byte i8Val;
+ protected short i16Val;
+ protected int i32Val;
+ protected char charVal;
+ protected float f32Val;
+ protected double f64Val;
+ protected String stringVal;
+ protected int[] arrayFromInt32 =new int[10];
//--------------------- attribute setters and getters
public void setI8Val (byte i8Val) {
this.i8Val = i8Val;
}
public byte getI8Val () {
- return i8Val;
+ return this.i8Val;
}public void setI16Val (short i16Val) {
this.i16Val = i16Val;
}
public short getI16Val () {
- return i16Val;
+ return this.i16Val;
}public void setI32Val (int i32Val) {
this.i32Val = i32Val;
}
public int getI32Val () {
- return i32Val;
+ return this.i32Val;
}public void setCharVal (char charVal) {
this.charVal = charVal;
}
public char getCharVal () {
- return charVal;
+ return this.charVal;
}public void setF32Val (float f32Val) {
this.f32Val = f32Val;
}
public float getF32Val () {
- return f32Val;
+ return this.f32Val;
}public void setF64Val (double f64Val) {
this.f64Val = f64Val;
}
public double getF64Val () {
- return f64Val;
+ return this.f64Val;
}public void setStringVal (String stringVal) {
this.stringVal = stringVal;
}
public String getStringVal () {
- return stringVal;
+ return this.stringVal;
}public void setArrayFromInt32 (int[] arrayFromInt32) {
this.arrayFromInt32 = arrayFromInt32;
}
public int[] getArrayFromInt32 () {
- return arrayFromInt32;
+ return this.arrayFromInt32;
}
//--------------------- operations

Back to the top