summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-07-29 18:13:24 +1000
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-07-31 11:16:34 +1000
commit29202f033c87b5efe305e606805a26c59886875b (patch)
tree6d0b770e58a67648f64fd90c6be9f5e2ee45c5f6 /src/tools
parentf5acc7b83f79c0bce554a6e4fe2d9e6ebb4b582b (diff)
Add CONSTANT attribute to Q_PROPERTY()
This will be used by the declarative module to determine if a property lacking a NOTIFY signal is truly constant, or just missing a NOTIFY signal. Reviewed-by: Roberto Raggi
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/moc/generator.cpp7
-rw-r--r--src/tools/moc/moc.cpp23
-rw-r--r--src/tools/moc/moc.h3
3 files changed, 31 insertions, 2 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
index b872dfd6fe..e4086e647b 100644
--- a/src/tools/moc/generator.cpp
+++ b/src/tools/moc/generator.cpp
@@ -66,7 +66,9 @@ enum PropertyFlags {
ResolveEditable = 0x00080000,
User = 0x00100000,
ResolveUser = 0x00200000,
- Notify = 0x00400000
+ Notify = 0x00400000,
+ Dynamic = 0x00800000,
+ Constant = 0x00000400
};
enum MethodFlags {
AccessPrivate = 0x00,
@@ -597,6 +599,9 @@ void Generator::generateProperties()
if (p.notifyId != -1)
flags |= Notify;
+ if (p.constant)
+ flags |= Constant;
+
fprintf(out, " %4d, %4d, ",
strreg(p.name),
strreg(p.type));
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index 797595f839..66012caca0 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -908,6 +908,12 @@ void Moc::parseProperty(ClassDef *def)
propDef.name = lexem();
while (test(IDENTIFIER)) {
QByteArray l = lexem();
+
+ if (l[0] == 'C' && l == "CONSTANT") {
+ propDef.constant = true;
+ continue;
+ }
+
QByteArray v, v2;
if (test(LPAREN)) {
v = lexemUntil(RPAREN);
@@ -963,6 +969,23 @@ void Moc::parseProperty(ClassDef *def)
msg += " has no READ accessor function. The property will be invalid.";
warning(msg.constData());
}
+ if (propDef.constant && !propDef.write.isNull()) {
+ QByteArray msg;
+ msg += "Property declaration ";
+ msg += propDef.name;
+ msg += " is both WRITEable and CONSTANT. CONSTANT will be ignored.";
+ propDef.constant = false;
+ warning(msg.constData());
+ }
+ if (propDef.constant && !propDef.notify.isNull()) {
+ QByteArray msg;
+ msg += "Property declaration ";
+ msg += propDef.name;
+ msg += " is both NOTIFYable and CONSTANT. CONSTANT will be ignored.";
+ propDef.constant = false;
+ warning(msg.constData());
+ }
+
if(!propDef.notify.isEmpty())
def->notifyableProperties++;
diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h
index 9fa9ac2e28..494d53e943 100644
--- a/src/tools/moc/moc.h
+++ b/src/tools/moc/moc.h
@@ -115,9 +115,10 @@ struct FunctionDef
struct PropertyDef
{
- PropertyDef():notifyId(-1), gspec(ValueSpec){}
+ PropertyDef():notifyId(-1), constant(false), gspec(ValueSpec){}
QByteArray name, type, read, write, reset, designable, scriptable, editable, stored, user, notify;
int notifyId;
+ bool constant;
enum Specification { ValueSpec, ReferenceSpec, PointerSpec };
Specification gspec;
bool stdCppSet() const {