Commit 80259b2e authored by Juergen Haug's avatar Juergen Haug
Browse files

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

Change-Id: I1f59ae1bede4194160357f03f02eb4bd44c3efd0
parent 994f5eb9
......@@ -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>();
......
......@@ -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));
}
'''}
......
......@@ -374,6 +374,7 @@ class ProcedureHelpers {
DataClass case !inherited: structors
ActorClass case inherited: allStructors
DataClass case inherited: allStructors
default: emptyList
}
}
......
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment