Bug 550253 - fixed inherited dataclass operations + added warn for ctor

Change-Id: I1f59ae1bede4194160357f03f02eb4bd44c3efd0
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 20787ca..75ab3b2 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 @@
 
 	@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 5e4b835..47ac9fe 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 @@
 		
 «««		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 @@
 		
 		«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 e60a074..0ccd90f 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 @@
 			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 d8bc33c..9520754 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 @@
 					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 @@
 						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 @@
 		}
 	}
 
+	/** 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