Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java11
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend9
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend1
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/OperationInheritanceTest.room40
4 files changed, 34 insertions, 27 deletions
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java
index 20787cae2..75ab3b211 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java
@@ -685,10 +685,17 @@ public class RoomJavaValidator extends AbstractRoomJavaValidator {
@Check
public void checkDataClass(DataClass dc) {
- if (dc.getAttributes().isEmpty() && dc.getBase()==null)
+ if (dc.getAttributes().isEmpty() && dc.getBase() == null) {
error("Non-derived data classes have to define at least one attribute", RoomPackage.Literals.DATA_CLASS__ATTRIBUTES);
+ }
+ dc.getStructors().stream().filter((op) -> op.isConstructor()).forEach((dtor) -> {
+ warning("Not implemented for C generation", dtor, null);
+ });
+ dc.getStructors().stream().filter((op) -> !op.isConstructor()).forEach((dtor) -> {
+ error("DataClass cannot have a destructor", dtor, null);
+ });
}
-
+
@Check
public void checkReplicatedPortBindingPatterns(StructureClass sc) {
HashSet<String> haveReplPeer = new HashSet<String>();
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 5e4b83525..47ac9fe28 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
@@ -87,7 +87,7 @@ class DataClassGen {
««« TODO: do we need setters and getters for C and C++ ?
- «dc.operations.operationsDeclaration(dc.name)»
+ «dc.latestOperations.operationsDeclaration(dc.name)»
/* deep copy */
void «dc.name»_deepCopy(«dc.name»* source, «dc.name»* target);
@@ -167,15 +167,14 @@ class DataClassGen {
«dc.userCode(3)»
-««« TODO: do we need setters and getters for C and C++ ?
-
- «dc.operations.operationsImplementation(dc.name)»
+ ««« TODO: do we need setters and getters for C and C++ ?
+
+ «dc.latestOperations.operationsImplementation(dc.name)»
void «dc.name»_deepCopy(«dc.name»* source, «dc.name»* target) {
memcpy(target, source, sizeof(«dc.name»));
}
-
'''}
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 e60a074e8..0ccd90fb5 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
@@ -374,6 +374,7 @@ class ProcedureHelpers {
DataClass case !inherited: structors
ActorClass case inherited: allStructors
DataClass case inherited: allStructors
+ default: emptyList
}
}
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/OperationInheritanceTest.room b/tests/org.eclipse.etrice.generator.common.tests/models/OperationInheritanceTest.room
index d8bc33ce1..9520754f3 100644
--- a/tests/org.eclipse.etrice.generator.common.tests/models/OperationInheritanceTest.room
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/OperationInheritanceTest.room
@@ -21,9 +21,9 @@ RoomModel OperationInheritanceTest {
action '''
baseOperation();
overriddenOperation();
- // c: not supported yet
+ // c: not supported in detail code translator
//testDataClass.baseOperation();
- //testDataClass.overriddenOperation(caseId);
+ //testDataClass.overriddenOperation();
// refine ctor, override operations
// -- ActorClass
@@ -33,11 +33,12 @@ RoomModel OperationInheritanceTest {
EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 2, valueSub);
// -- DataClass
- //EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 1, testDataClass.ctorBase);
- //EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 2, testDataClass.ctorRefine);
- //EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 1, testDataClass.valueBase);
- //EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 2, testDataClass.valueSub);
- //EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 0, testDataClass.doNotCallOverride);
+ // cannot work due missing calls, see above
+ //EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 1, testDataClass.ctorBase_);
+ //EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 2, testDataClass.ctorRefine_);
+ //EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 1, testDataClass.valueBase_);
+ //EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 2, testDataClass.valueSub_);
+ //EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 0, testDataClass.doNotCallOverride_);
etUnit_testFinished(caseId);'''
}
State finish
@@ -63,23 +64,22 @@ RoomModel OperationInheritanceTest {
}
}
+ /** the suffix '_' is necessary for C due macros :( */
DataClass BaseDataClass {
- Operation overriddenOperation() '''doNotCallOverride = 1;'''
- Operation baseOperation() '''valueBase = 1;'''
+ Operation overriddenOperation() '''doNotCallOverride_ = 1;'''
+ Operation baseOperation() '''valueBase_ = 1;'''
ctor '''
- ctorBase = 1;
- ctorRefine = 1;'''
- dtor '''// base dtor'''
- Attribute ctorBase: int32 = "0"
- Attribute ctorRefine: int32 = "0"
- Attribute valueBase: int32 = "0"
- Attribute valueSub: int32 = "0"
- Attribute doNotCallOverride: int32 = "0"
+ ctorBase_ = 1;
+ ctorRefine_ = 1;'''
+ Attribute ctorBase_: int32 = "0"
+ Attribute ctorRefine_: int32 = "0"
+ Attribute valueBase_: int32 = "0"
+ Attribute valueSub_: int32 = "0"
+ Attribute doNotCallOverride_: int32 = "0"
}
DataClass SubDataClass extends BaseDataClass {
- override Operation overriddenOperation() '''valueSub = 2;'''
- ctor '''ctorRefine = 2;'''
- dtor '''// sub dtor'''
+ override Operation overriddenOperation() '''valueSub_ = 2;'''
+ ctor '''ctorRefine_ = 2;'''
}
} \ No newline at end of file

Back to the top