summaryrefslogtreecommitdiffstats
path: root/tools/repc/repcodegenerator.cpp
diff options
context:
space:
mode:
authorBrett Stottlemyer <bstottle@ford.com>2018-04-23 11:08:18 -0400
committerMichael Brasser <michael.brasser@live.com>2018-04-25 17:32:38 +0000
commite8cadf8f88128758725ef7498ed7164751095832 (patch)
tree9f24e898e6922adee4ae34adb5a5355ce8a0e41d /tools/repc/repcodegenerator.cpp
parent270e8e1d7884fb5e7864bac5b752678c7bd1cf5f (diff)
Support non-CONSTANT pointer types
Prior to supporting nested source objects (internally), there was no way to support changing pointed to objects. Thus repc forced MODEL and CLASS types to be CONSTANT. This change adds update support, which required a few internal changes. First of all, the Q_PROPERTY flags were extended to include a new mode, SOURCEONLYSETTER. Having a replica setter for a pointer type makes no sense (it wouldn't then be part of the API contract, and would fail if the Node containing the replica dropped off the bus). So READWRITE didn't make sense for pointer types. That left READONLY, but that mode generated a protected, not public, setter on the Source side (the idea being that something internal to the source class, not public, would change the values). This would limit the functionality of pointer types, as they could only be updated by inheriting from a Source class. Adding SOURCEONLYSETTER addresses this, making the property read-only on the replica-side, but read/write (with a public setter) on the source-side. MODEL/CLASS now use SOURCEONLYSETTER. Another internal impact is that templated acquire calls (where metaobject data does not need to be sent from the source to define the type) can now be updated, which requires storing the compile-time generated metaobject for re-use. Thus a staticTypes member was added to the node metaoject- manager. Several tests (the ones with pointer-to-qobject properties) needed updating since those properties are not constant anymore, and thus don't have (or require) constructor parameters for setting the values. Change-Id: If20cb0fb673d5e91613f9c238b514ed05380f975 Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'tools/repc/repcodegenerator.cpp')
-rw-r--r--tools/repc/repcodegenerator.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/repc/repcodegenerator.cpp b/tools/repc/repcodegenerator.cpp
index b3c495b..d1cbe84 100644
--- a/tools/repc/repcodegenerator.cpp
+++ b/tools/repc/repcodegenerator.cpp
@@ -640,7 +640,7 @@ void RepCodeGenerator::generateClass(Mode mode, QTextStream &out, const ASTClass
out << " NOTIFY " << property.name << "Changed";
else if (property.modifier == ASTProperty::ReadWrite)
out << " WRITE set" << cap(property.name) << " NOTIFY " << property.name << "Changed";
- else if (property.modifier == ASTProperty::ReadPush) {
+ else if (property.modifier == ASTProperty::ReadPush || property.modifier == ASTProperty::SourceOnlySetter) {
if (mode == REPLICA) // The setter slot isn't known to the PROP
out << " NOTIFY " << property.name << "Changed";
else // The Source can use the setter, since non-asynchronous
@@ -823,7 +823,8 @@ void RepCodeGenerator::generateClass(Mode mode, QTextStream &out, const ASTClass
out << " virtual " << typeForMode(property, mode) << " " << property.name << "() const = 0;" << endl;
Q_FOREACH (const ASTProperty &property, astClass.properties) {
if (property.modifier == ASTProperty::ReadWrite ||
- property.modifier == ASTProperty::ReadPush)
+ property.modifier == ASTProperty::ReadPush ||
+ property.modifier == ASTProperty::SourceOnlySetter)
out << " virtual void set" << cap(property.name) << "(" << typeForMode(property, mode) << " " << property.name << ") = 0;" << endl;
}
} else {
@@ -832,7 +833,8 @@ void RepCodeGenerator::generateClass(Mode mode, QTextStream &out, const ASTClass
<< property.name << "; }" << endl;
Q_FOREACH (const ASTProperty &property, astClass.properties) {
if (property.modifier == ASTProperty::ReadWrite ||
- property.modifier == ASTProperty::ReadPush) {
+ property.modifier == ASTProperty::ReadPush ||
+ property.modifier == ASTProperty::SourceOnlySetter) {
generateSimpleSetter(out, property);
}
}